]> code.citadel.org Git - citadel.git/commitdiff
* Implement the NAMESPACE extension of IMAP (RFC 2342)
authorArt Cancro <ajc@citadel.org>
Mon, 1 Mar 2004 22:36:14 +0000 (22:36 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 1 Mar 2004 22:36:14 +0000 (22:36 +0000)
citadel/ChangeLog
citadel/serv_imap.c

index b992eeaf3107804ffa2d869a060781407eb98a11..6c635907550393cfd4b43b32228df7ffac42ac8a 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 614.61  2004/03/01 22:36:14  ajc
+ * Implement the NAMESPACE extension of IMAP (RFC 2342)
+
  Revision 614.60  2004/03/01 17:47:28  error
  * Fix missing arg in m<Y> next rewrite.
 
@@ -5440,4 +5443,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 58de3561e2a02d6ce4096c2821361c56724d276b..95c2ce7d19de96a78584ef621405069583f19e25 100644 (file)
@@ -409,7 +409,7 @@ void imap_auth_login_pass(char *cmd)
  */
 void imap_capability(int num_parms, char *parms[])
 {
-       cprintf("* CAPABILITY IMAP4 IMAP4REV1 AUTH=LOGIN");
+       cprintf("* CAPABILITY IMAP4 IMAP4REV1 NAMESPACE AUTH=LOGIN");
 
 #ifdef HAVE_OPENSSL
        cprintf(" STARTTLS");
@@ -602,6 +602,44 @@ void imap_close(int num_parms, char *parms[])
 }
 
 
+/*
+ * Implements the NAMESPACE command.
+ */
+void imap_namespace(int num_parms, char *parms[])
+{
+       int i;
+       struct floor *fl;
+       int floors = 0;
+       char buf[SIZ];
+
+       cprintf("* NAMESPACE ");
+
+       /* All personal folders are subordinate to INBOX. */
+       cprintf("((\"INBOX|\" \"|\")) ");
+
+       /* Other users' folders ... coming soon! FIXME */
+       cprintf("NIL ");
+
+       /* Show all floors as shared namespaces.  Neato! */
+       cprintf("(");
+       for (i = 0; i < MAXFLOORS; ++i) {
+               fl = cgetfloor(i);
+               if (fl->f_flags & F_INUSE) {
+                       if (floors > 0) cprintf(" ");
+                       cprintf("(");
+                       sprintf(buf, "%s|", fl->f_name);
+                       imap_strout(buf);
+                       cprintf(" \"|\")");
+                       ++floors;
+               }
+       }
+       cprintf(")");
+
+       /* Wind it up with a newline and a completion message. */
+       cprintf("\r\n");
+       cprintf("%s OK NAMESPACE completed\r\n", parms[0]);
+}
+
 
 
 /*
@@ -1317,6 +1355,10 @@ void imap_command_loop(void)
                imap_append(num_parms, parms);
        }
 
+       else if (!strcasecmp(parms[1], "NAMESPACE")) {
+               imap_namespace(num_parms, parms);
+       }
+
        else if (IMAP->selected == 0) {
                cprintf("%s BAD no folder selected\r\n", parms[0]);
        }