]> code.citadel.org Git - citadel.git/blobdiff - citadel/serv_imap.c
* Replaced all "Citadel/UX" references with "Citadel"
[citadel.git] / citadel / serv_imap.c
index bee2dedb1077b1b2333523dc3ed58e1f820f712f..e456f925ff790cac60e17e62a799cbb5777814ca 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * $Id$ 
  *
- * IMAP server for the Citadel/UX system
+ * IMAP server for the Citadel system
  * Copyright (C) 2000-2002 by Art Cancro and others.
  * This code is released under the terms of the GNU General Public License.
  *
@@ -305,6 +305,11 @@ void imap_cleanup_function(void)
        if (CC->h_command_function != imap_command_loop)
                return;
 
+       /* If there is a mailbox selected, auto-expunge it. */
+       if (IMAP->selected) {
+               imap_do_expunge();
+       }
+
        lprintf(CTDL_DEBUG, "Performing IMAP cleanup hook\n");
        imap_free_msgids();
        imap_free_transmitted_message();
@@ -338,7 +343,7 @@ void imap_greeting(void)
        IMAP->cached_fetch = NULL;
        IMAP->cached_msgnum = (-1);
 
-       cprintf("* OK %s Citadel/UX IMAP4rev1 server ready\r\n",
+       cprintf("* OK %s Citadel IMAP4rev1 server ready\r\n",
                config.c_fqdn);
 }
 
@@ -513,7 +518,6 @@ void imap_select(int num_parms, char *parms[])
        if (!ok) {
                cprintf("%s NO ... no such room, or access denied\r\n",
                        parms[0]);
-               /* IMAP->selected = 0; */
                return;
        }
 
@@ -564,8 +568,9 @@ int imap_do_expunge(void)
        int num_expunged = 0;
 
        lprintf(CTDL_DEBUG, "imap_do_expunge() called\n");
-       if (IMAP->selected == 0)
+       if (IMAP->selected == 0) {
                return (0);
+       }
 
        if (IMAP->num_msgs > 0)
                for (i = 0; i < IMAP->num_msgs; ++i) {
@@ -573,11 +578,6 @@ int imap_do_expunge(void)
                                CtdlDeleteMessages(CC->room.QRname,
                                                   IMAP->msgids[i], "");
                                ++num_expunged;
-                               lprintf(CTDL_DEBUG, "%ld ... deleted\n",
-                                       IMAP->msgids[i]);
-                       } else {
-                               lprintf(CTDL_DEBUG, "%ld ... not deleted\n",
-                                       IMAP->msgids[i]);
                        }
                }
 
@@ -585,6 +585,7 @@ int imap_do_expunge(void)
                imap_rescan_msgids();
        }
 
+       lprintf(9, "Expunged %d messages.\n", num_expunged);
        return (num_expunged);
 }
 
@@ -608,7 +609,9 @@ void imap_close(int num_parms, char *parms[])
 {
 
        /* Yes, we always expunge on close. */
-       imap_do_expunge();
+       if (IMAP->selected) {
+               imap_do_expunge();
+       }
 
        IMAP->selected = 0;
        IMAP->readonly = 0;
@@ -630,7 +633,7 @@ void imap_namespace(int num_parms, char *parms[])
        cprintf("* NAMESPACE ");
 
        /* All personal folders are subordinate to INBOX. */
-       cprintf("((\"INBOX|\" \"|\")) ");
+       cprintf("((\"INBOX/\" \"/\")) ");
 
        /* Other users' folders ... coming soon! FIXME */
        cprintf("NIL ");
@@ -642,9 +645,9 @@ void imap_namespace(int num_parms, char *parms[])
                if (fl->f_flags & F_INUSE) {
                        if (floors > 0) cprintf(" ");
                        cprintf("(");
-                       sprintf(buf, "%s|", fl->f_name);
+                       sprintf(buf, "%s/", fl->f_name);
                        imap_strout(buf);
-                       cprintf(" \"|\")");
+                       cprintf(" \"/\")");
                        ++floors;
                }
        }
@@ -670,7 +673,7 @@ void imap_list_floors(char *cmd, char *pattern)
                if (fl->f_flags & F_INUSE) {
                        if (imap_mailbox_matches_pattern
                            (pattern, fl->f_name)) {
-                               cprintf("* %s (\\NoSelect) \"|\" ", cmd);
+                               cprintf("* %s (\\NoSelect) \"/\" ", cmd);
                                imap_strout(fl->f_name);
                                cprintf("\r\n");
                        }
@@ -699,7 +702,7 @@ void imap_lsub_listroom(struct ctdlroom *qrbuf, void *data)
        if (ra & UA_KNOWN) {
                imap_mailboxname(buf, sizeof buf, qrbuf);
                if (imap_mailbox_matches_pattern(pattern, buf)) {
-                       cprintf("* LSUB () \"|\" ");
+                       cprintf("* LSUB () \"/\" ");
                        imap_strout(buf);
                        cprintf("\r\n");
                }
@@ -720,7 +723,7 @@ void imap_lsub(int num_parms, char *parms[])
        snprintf(pattern, sizeof pattern, "%s%s", parms[2], parms[3]);
 
        if (strlen(parms[3]) == 0) {
-               cprintf("* LIST (\\Noselect) \"|\" \"\"\r\n");
+               cprintf("* LIST (\\Noselect) \"/\" \"\"\r\n");
        }
 
        else {
@@ -750,7 +753,7 @@ void imap_list_listroom(struct ctdlroom *qrbuf, void *data)
            || ((ra & UA_GOTOALLOWED) && (ra & UA_ZAPPED))) {
                imap_mailboxname(buf, sizeof buf, qrbuf);
                if (imap_mailbox_matches_pattern(pattern, buf)) {
-                       cprintf("* LIST () \"|\" ");
+                       cprintf("* LIST () \"/\" ");
                        imap_strout(buf);
                        cprintf("\r\n");
                }
@@ -771,7 +774,7 @@ void imap_list(int num_parms, char *parms[])
        snprintf(pattern, sizeof pattern, "%s%s", parms[2], parms[3]);
 
        if (strlen(parms[3]) == 0) {
-               cprintf("* LIST (\\Noselect) \"|\" \"\"\r\n");
+               cprintf("* LIST (\\Noselect) \"/\" \"\"\r\n");
        }
 
        else {
@@ -814,7 +817,7 @@ void imap_create(int num_parms, char *parms[])
        flags = (ret & 0xff00); /* upper 8 bits = flags        */
 
        if (flags & IR_MAILBOX) {
-               if (strncasecmp(parms[2], "INBOX|", 6)) {
+               if (strncasecmp(parms[2], "INBOX/", 6)) {
                        cprintf("%s NO Personal folders must be created under INBOX\r\n", parms[0]);
                        lprintf(CTDL_DEBUG, "not subordinate to inbox\n");
                        return;
@@ -1110,9 +1113,9 @@ void imap_rename_backend(struct ctdlroom *qrbuf, void *data)
        /* Rename subfolders */
        if ((!strncasecmp(foldername, irlparms->oldname,
                          strlen(irlparms->oldname))
-            && (foldername[strlen(irlparms->oldname)] == '|'))) {
+            && (foldername[strlen(irlparms->oldname)] == '/'))) {
 
-               sprintf(newfoldername, "%s|%s",
+               sprintf(newfoldername, "%s/%s",
                        irlparms->newname,
                        &foldername[strlen(irlparms->oldname) + 1]
                    );
@@ -1267,7 +1270,7 @@ void imap_command_loop(void)
        /* Ok, at this point we're in normal command mode.  The first thing
         * we do is print any incoming pages (yeah! we really do!)
         */
-       imap_print_express_messages();
+       imap_print_instant_messages();
 
        /*
         * Before processing the command that was just entered... if we happen
@@ -1296,7 +1299,9 @@ void imap_command_loop(void)
        }
 
        else if (!strcasecmp(parms[1], "LOGOUT")) {
-               imap_do_expunge();      /* yes, we auto-expunge */
+               if (IMAP->selected) {
+                       imap_do_expunge();      /* yes, we auto-expunge */
+               }
                cprintf("* BYE %s logging out\r\n", config.c_fqdn);
                cprintf("%s OK thank you for using Citadel IMAP\r\n",
                        parms[0]);
@@ -1444,7 +1449,7 @@ void imap_command_loop(void)
 char *serv_imap_init(void)
 {
        CtdlRegisterServiceHook(config.c_imap_port,
-                               NULL, imap_greeting, imap_command_loop);
+                               NULL, imap_greeting, imap_command_loop, NULL);
        CtdlRegisterSessionHook(imap_cleanup_function, EVT_STOP);
        return "$Id$";
 }