8 messages in net.sourceforge.lists.courier-sqwebmailRe: [sqwebmail] Problem with renaming...
FromSent OnAttachments
Pawel TeczaMay 11, 2006 7:53 am 
Sam VarshavchikMay 11, 2006 3:29 pm 
Pawel TeczaMay 12, 2006 12:11 am 
Pawel TeczaMay 12, 2006 3:15 am 
Sam VarshavchikMay 12, 2006 4:03 pm 
Lars AlthofMay 12, 2006 5:34 pm 
Sam VarshavchikMay 12, 2006 8:08 pm 
Pawel TeczaMay 15, 2006 1:06 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [sqwebmail] Problem with renaming Sent folderActions...
From:Sam Varshavchik (mrs@courier-mta.com)
Date:May 12, 2006 8:08:29 pm
List:net.sourceforge.lists.courier-sqwebmail

Pawel Tecza writes:

On Fri, 12 May 2006, Pawel Tecza wrote:

On Thu, 11 May 2006, Sam Varshavchik wrote:

[...]

But you shouldn't get double folders, unless something else is broken, because sqwebmail should only attempt to create the sent folder once.

OK, I'll look at this and try to find a bug.

The Sqwebmail creates the Sent folder once, but it does it for _each_ language version, if they use _different_ locale. It's because of the following line in the rename_sent_folder() function (sqwebmail.c file):

if (strftime (buf, sizeof(buf), "." SENT ".%Y.%m-%b", tm) == 0) return;

For example, assume that I don't have any .Sent.2006.04* folders. If I login to English version of the webmail ('en_US' locale), then it checks .Sent.2006.04-Apr folder and creates it, because the folder doesn't exist yet. If I login to Polish version of the webmail ('pl_PL' locale), then it checks .Sent.2006.04-kwi folder and also creates it, because the folder doesn't exist yet.

So, I propose to remove "-%b" prefix from the line above. If the abbreviated month name is so important for you there, you could add it while displaying names of .Sent folders. For example, if I have .Sent.2006.04 folder, then I'll see .Sent.2006.04-Apr folder in English version of the webmail and .Sent.2006.04-kwi folder in Polish. What do you think about it?

My best regards,

Here's an untested patch:

Index: webmail/sqwebmail.c =================================================================== RCS file: /cvsroot/courier/courier/webmail/sqwebmail.c,v retrieving revision 1.133 diff -U3 -r1.133 sqwebmail.c --- webmail/sqwebmail.c 3 May 2006 22:46:15 -0000 1.133 +++ webmail/sqwebmail.c 13 May 2006 03:07:37 -0000 @@ -2065,12 +2065,16 @@

static void rename_sent_folder() { - char buf[128], buf2[200]; + char buf[128]; + char yyyymm[128]; + const char *yyyymmp; + time_t t; struct tm *tm; - struct stat stat_buf; char *pp;

+ (void)maildir_create(INBOX "." SENT); /* No matter what */ + time(&t); tm=localtime(&t); if (!tm) @@ -2084,20 +2088,23 @@ else --tm->tm_mon;

- if (strftime (buf, sizeof(buf), "." SENT ".%Y.%m-%b", tm) == 0) + if (strftime (yyyymm, sizeof(yyyymm), "%Y%m", tm) == 0) return;

- strcat(strcpy(buf2, "." SENT "/sqwebmail"), buf); + if ((yyyymmp=read_sqconfig(".", SENTSTAMP, NULL)) != NULL && + strcmp(yyyymm, yyyymmp) == 0) + return;

- if (stat(buf2, &stat_buf) == 0) - return; /* Already renamed */ + if (strftime (buf, sizeof(buf), "." SENT ".%Y.%m-%b", tm) == 0) + return;

pp=folder_toutf7(buf);

rename("." SENT, pp); free(pp); (void)maildir_create(INBOX "." SENT); - close(open(buf2, O_RDWR|O_CREAT, 0600)); + + write_sqconfig(".", SENTSTAMP, yyyymm); }

static int valid_redirect(); Index: webmail/sqwebmail.h =================================================================== RCS file: /cvsroot/courier/courier/webmail/sqwebmail.h,v retrieving revision 1.20 diff -U3 -r1.20 sqwebmail.h --- webmail/sqwebmail.h 31 Jan 2006 00:11:47 -0000 1.20 +++ webmail/sqwebmail.h 13 May 2006 03:07:37 -0000 @@ -55,6 +55,10 @@

#define IPFILE "sqwebmail-ip"

+/* Last time the sent folder was renamed */ + +#define SENTSTAMP "sqwebmail-sentstamp" + /* File that keeps the time of last access */

#define TIMESTAMP "sqwebmail-timestamp"