Bitt Faulk wrote:
> 
> I'll post the patch a little later tonight or tomorrow after I've had
> a little bit of a chance to test it against 2.0.11.  Might as well
> add your suggestion first :-)

Okay.  Done.  It's not fully tested, but I'm pretty sure it's right.

It only works for imap clients, not pop, but you should be able to cram
something into pop3d.c around line 1049 to get it to do the same thing.
I'd still suggest that you not do that, as pop sucks(TM), IMHO.

-Bitt
*** cyrus-imapd-2.0.11/imap/imapd.c     Fri Jan 19 11:37:28 2001
--- imap/imapd.c        Thu Feb  8 18:02:54 2001
***************
*** 2211,2217 ****
--- 2211,2224 ----
  {
      struct mailbox mailbox;
      char mailboxname[MAX_MAILBOX_NAME+1];
+     char add_name[MAX_MAILBOX_NAME+1];   /* I'm not happy about this buffer, but
+                                             since "INBOX." can be no bigger than
+                                             "user.*", it *should* be okay. */
+     char add_mailboxname[MAX_MAILBOX_NAME+1];
+     char *autofolders;
+     char *autofolder;
      int r = 0;
+     int r_tmp;
      double usage;
      int doclose = 0;
  
***************
*** 2231,2236 ****
--- 2238,2281 ----
  
      if (!r) {
        r = mailbox_open_header(mailboxname, imapd_authstate, &mailbox);
+       if (r == IMAP_MAILBOX_NONEXISTENT &&
+           !strncasecmp(name, "INBOX", 6) &&
+           config_getint("autocreatequota", 0)) {   /* Autocreate INBOX */
+           r = mboxlist_createmailbox(mailboxname, MAILBOX_FORMAT_NORMAL,
+                                      NULL, 1, imapd_userid,
+                                      imapd_authstate);
+           if (!r) {
+               r = mailbox_open_header(mailboxname, imapd_authstate,
+                                       &mailbox);
+           }
+           r_tmp = r;   /* Save return value for later */
+ 
+           if (!r) {
+               /* Deal with surreptitiously creating additional folders */
+               autofolders = strdup(config_getstring("autocreatefolders", ""));
+               autofolder = strtok(autofolders, " ");
+               while (autofolder != NULL) {
+                   add_name[0] = '\0';
+                   strcat(add_name, name);
+                   strcat(add_name, ".");
+                   strcat(add_name, autofolder);
+                   r = mboxname_tointernal(add_name, imapd_userid, add_mailboxname);
+                   if (!r) {
+                       /* Throw away return because errors cannot be fatal and
+                          there's no way to report them.  syslog() maybe? */
+                       (void)mboxlist_createmailbox(add_mailboxname,
+                                                    MAILBOX_FORMAT_NORMAL,
+                                                    NULL, 1, imapd_userid,
+                                                    imapd_authstate);
+                   }
+                   /* I hope there are no intervening strtok()s */
+                   autofolder = strtok(NULL, " ");
+               }
+               free(autofolders);
+           }
+ 
+           r = r_tmp;   /* Replace ``original'' return value */
+       }
      }
  
      if (!r) {

Reply via email to