]> code.citadel.org Git - citadel.git/blobdiff - citadel/modules/imap/serv_imap.c
Completed the implementation of RFC2359
[citadel.git] / citadel / modules / imap / serv_imap.c
index 46b2053978c2c1fde4a9efccdf8d04f07b2ef478..098ce942f5c520b402bac201ebb1a4fed42de264 100644 (file)
@@ -435,12 +435,16 @@ void imap_cleanup_function(void)
  * output this stuff in other places as well)
  */
 void imap_output_capability_string(void) {
-       cprintf("CAPABILITY IMAP4REV1 NAMESPACE ID ACL AUTH=PLAIN AUTH=LOGIN");
+       cprintf("CAPABILITY IMAP4REV1 NAMESPACE ID AUTH=PLAIN AUTH=LOGIN UIDPLUS");
 
 #ifdef HAVE_OPENSSL
        if (!CC->redirect_ssl) cprintf(" STARTTLS");
 #endif
 
+#ifndef DISABLE_IMAP_ACL
+       cprintf(" ACL");
+#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
@@ -504,6 +508,9 @@ void imap_greeting(void)
  */
 void imaps_greeting(void) {
        CtdlModuleStartCryptoMsgs(NULL, NULL, NULL);
+#ifdef HAVE_OPENSSL
+       if (!CC->redirect_ssl) CC->kill_me = 1;         /* kill session if no crypto */
+#endif
        imap_greeting();
 }
 
@@ -731,7 +738,7 @@ void imap_select(int num_parms, char *parms[])
        cprintf("* %d EXISTS\r\n", msgs);
        cprintf("* %d RECENT\r\n", new);
 
-       cprintf("* OK [UIDVALIDITY 1] UID validity status\r\n");
+       cprintf("* OK [UIDVALIDITY %ld] UID validity status\r\n", GLOBAL_UIDVALIDITY_VALUE);
        cprintf("* OK [UIDNEXT %ld] Predicted next UID\r\n", CitControl.MMhighest + 1);
 
        /* Note that \Deleted is a valid flag, but not a permanent flag,
@@ -1545,8 +1552,7 @@ void imap_command_loop(void)
                imap_copy(num_parms, parms);
        }
 
-       else if ((!strcasecmp(parms[1], "UID"))
-                && (!strcasecmp(parms[2], "COPY"))) {
+       else if ((!strcasecmp(parms[1], "UID")) && (!strcasecmp(parms[2], "COPY"))) {
                imap_uidcopy(num_parms, parms);
        }
 
@@ -1554,6 +1560,10 @@ void imap_command_loop(void)
                imap_expunge(num_parms, parms);
        }
 
+       else if ((!strcasecmp(parms[1], "UID")) && (!strcasecmp(parms[2], "EXPUNGE"))) {
+               imap_expunge(num_parms, parms);
+       }
+
        else if (!strcasecmp(parms[1], "CLOSE")) {
                imap_close(num_parms, parms);
        }
@@ -1578,16 +1588,19 @@ void imap_command_loop(void)
 }
 
 
+const char *CitadelServiceIMAP="IMAP";
+const char *CitadelServiceIMAPS="IMAPS";
+
 /*
  * This function is called to register the IMAP extension with Citadel.
  */
 CTDL_MODULE_INIT(imap)
 {
        CtdlRegisterServiceHook(config.c_imap_port,
-                               NULL, imap_greeting, imap_command_loop, NULL);
+                               NULL, imap_greeting, imap_command_loop, NULL, CitadelServiceIMAP);
 #ifdef HAVE_OPENSSL
        CtdlRegisterServiceHook(config.c_imaps_port,
-                               NULL, imaps_greeting, imap_command_loop, NULL);
+                               NULL, imaps_greeting, imap_command_loop, NULL, CitadelServiceIMAPS);
 #endif
        CtdlRegisterSessionHook(imap_cleanup_function, EVT_STOP);