]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_imap.c
Renamed validpw() in auth.c to validate_password()
[citadel.git] / citadel / serv_imap.c
index 616538ddcb4e630e7462013878ac34c329a8cdc1..d6b0fd89636c382b99265a9a098b62543aeb7969 100644 (file)
 #include "internet_addressing.h"
 #include "serv_imap.h"
 #include "imap_tools.h"
+#include "imap_list.h"
 #include "imap_fetch.h"
 #include "imap_search.h"
 #include "imap_store.h"
 #include "imap_acl.h"
+#include "imap_metadata.h"
 #include "imap_misc.h"
 
 #ifdef HAVE_OPENSSL
@@ -436,9 +438,18 @@ void imap_cleanup_function(void)
  */
 void imap_output_capability_string(void) {
        cprintf("CAPABILITY IMAP4REV1 NAMESPACE ID ACL AUTH=LOGIN");
+
 #ifdef HAVE_OPENSSL
        if (!CC->redirect_ssl) cprintf(" STARTTLS");
 #endif
+
+       /* We are building a partial implementation of METADATA for the sole purpose
+        * of interoperating with the ical/vcard version of the Bynari Insight Connector.
+        * If you were expecting something else, comment out one or both of these
+        * extension advertisements.
+        */
+       cprintf(" METADATA");
+       /* cprintf(" LIST-EXTENDED"); */
 }
 
 /*
@@ -814,128 +825,6 @@ void imap_namespace(int num_parms, char *parms[])
 
 
 
-/*
- * Used by LIST and LSUB to show the floors in the listing
- */
-void imap_list_floors(char *cmd, char *pattern)
-{
-       int i;
-       struct floor *fl;
-
-       for (i = 0; i < MAXFLOORS; ++i) {
-               fl = cgetfloor(i);
-               if (fl->f_flags & F_INUSE) {
-                       if (imap_mailbox_matches_pattern
-                           (pattern, fl->f_name)) {
-                               cprintf("* %s (\\NoSelect) \"/\" ", cmd);
-                               imap_strout(fl->f_name);
-                               cprintf("\r\n");
-                       }
-               }
-       }
-}
-
-
-
-/*
- * Back end for imap_lsub()
- *
- * IMAP "subscribed folder" is equivocated to Citadel "known rooms."  This
- * may or may not be the desired behavior in the future.
- */
-void imap_lsub_listroom(struct ctdlroom *qrbuf, void *data)
-{
-       char buf[SIZ];
-       int ra;
-       char *pattern;
-
-       pattern = (char *) data;
-
-       /* Only list rooms to which the user has access!! */
-       CtdlRoomAccess(qrbuf, &CC->user, &ra, NULL);
-       if (ra & UA_KNOWN) {
-               imap_mailboxname(buf, sizeof buf, qrbuf);
-               if (imap_mailbox_matches_pattern(pattern, buf)) {
-                       cprintf("* LSUB () \"/\" ");
-                       imap_strout(buf);
-                       cprintf("\r\n");
-               }
-       }
-}
-
-
-/*
- * Back end for imap_list()
- */
-void imap_list_listroom(struct ctdlroom *qrbuf, void *data)
-{
-       char buf[SIZ];
-       int ra;
-       char *pattern;
-
-       pattern = (char *) data;
-
-       /* Only list rooms to which the user has access!! */
-       CtdlRoomAccess(qrbuf, &CC->user, &ra, NULL);
-       if ((ra & UA_KNOWN)
-           || ((ra & UA_GOTOALLOWED) && (ra & UA_ZAPPED))) {
-               imap_mailboxname(buf, sizeof buf, qrbuf);
-               if (imap_mailbox_matches_pattern(pattern, buf)) {
-                       cprintf("* LIST () \"/\" ");
-                       imap_strout(buf);
-                       cprintf("\r\n");
-               }
-       }
-}
-
-
-/*
- * Implements the LIST and LSUB commands
- */
-void imap_list(int num_parms, char *parms[])
-{
-       char pattern[SIZ];
-       int subscribed_rooms_only = 0;
-       char verb[16];
-       int i, j;
-
-       if (num_parms < 4) {
-               cprintf("%s BAD arguments invalid\r\n", parms[0]);
-               return;
-       }
-
-       /* parms[1] is the IMAP verb being used (e.g. LIST or LSUB)
-        * This tells us how to behave, and what verb to return back to the caller
-        */
-       safestrncpy(verb, parms[1], sizeof verb);
-       j = strlen(verb);
-       for (i=0; i<j; ++i) {
-               verb[i] = toupper(verb[i]);
-       }
-
-       if (!strcasecmp(verb, "LSUB")) {
-               subscribed_rooms_only = 1;
-       }
-
-       snprintf(pattern, sizeof pattern, "%s%s", parms[2], parms[3]);
-
-       if (strlen(parms[3]) == 0) {
-               cprintf("* %s (\\Noselect) \"/\" \"\"\r\n", verb);
-       }
-
-       else {
-               imap_list_floors(verb, pattern);
-               ForEachRoom(
-                       (subscribed_rooms_only ? imap_lsub_listroom : imap_list_listroom),
-                       pattern
-               );
-       }
-
-       cprintf("%s OK %s completed\r\n", parms[0], verb);
-}
-
-
-
 /*
  * Implements the CREATE command
  *
@@ -1571,6 +1460,14 @@ void imap_command_loop(void)
                imap_myrights(num_parms, parms);
        }
 
+       else if (!strcasecmp(parms[1], "GETMETADATA")) {
+               imap_getmetadata(num_parms, parms);
+       }
+
+       else if (!strcasecmp(parms[1], "SETMETADATA")) {
+               imap_setmetadata(num_parms, parms);
+       }
+
        else if (IMAP->selected == 0) {
                cprintf("%s BAD no folder selected\r\n", parms[0]);
        }