Sam Varshavchik wrote:

[EMAIL PROTECTED] writes:

     Fixed. See the attachment.
------------------------------------------------------------------------
                                                From Beijing, China

I reviewed this patch in greater detail. And I still think that this is not right:

-       else if (strcmp(p, INBOX "." SENT) == 0)
+ else if (strcmp(p, INBOX "." SENT) == 0 || strcmp(path, SENT) == 0)
               printf("%s", n_sent);

In your original message, you wrote yourself:

"Translate folder name like ".Sent.*" when form=folders."

But that's wrong. The only context where "Sent" carries a special meaning is the top level Sent folder, INBOX.Sent. That's it. If there is some folder named INBOX.Foo.Bar.Sent.Baz, substituting the translated name for just the "Sent" part is wrong. Period.

Now, I understand that when you are displaying shared folders, some other mailbox's Sent folder will have a path other than INBOX.Sent, obviously, an thus not translated. That's certainly not 100% right, but this patch fixes it at the expense of breaking more stuff, and that's not the right solution.

I think that the right solution here is really to translate the actual folder names, instead of leaving the actual folder names as "Sent", "Drafts", and "Trash", and substituting their names on the fly.

That's going to be a much larger change, but that's going to be the correct solution. I'll put it on my list of things to do, but for now I'll leave things where they are, instead of making them even more convoluted.




    Actually, I believe there's no solution to current
list_folder_xlate() for a completist.
    The parameter p is given by an unpredictable folder's full name
inside current "directory". And the parameter path is given by only base
name of current "directory".
    If a folder is named ".Sent.foo.Sent.bar", and list_folder_xlate()
is called as:

    list_folder_xlate("INBOX.Sent.foo.Sent.bar", "Sent", ...)

I really cannot tell this "Sent" pointed by path from two "Sent" in the
folder's full name.

    Well, I provide you another patch, which only translates folder name
which matches "INBOX.Sent.*" and has only one whole section "Sent".

------------------------------------------------------------------------
                                               From Beijing, China



--- folder.c.orig       Tue Mar 14 07:36:16 2006
+++ folder.c    Thu Jun  1 18:53:25 2006
@@ -1068,7 +1068,14 @@
                printf("%s", n_drafts);
        else if (strcmp(p, INBOX "." TRASH) == 0)
                printf("%s", n_trash);
-       else if (strcmp(p, INBOX "." SENT) == 0)
+       else if (strcmp(p, INBOX "." SENT) == 0 /* Evaluated before the 
following */
+               || ( /* Matching "^\.Sent\." and not matching "\.Sent(\.|$)" 
behind. */
+                    strcmp(path, SENT) == 0
+                    && strncmp(p, INBOX "." SENT ".", strlen(INBOX "." SENT 
".")) == 0 /* Evaluated before the following */
+                    && !strstr(p+strlen(INBOX "." SENT "."), "." SENT ".") /* 
No "\.Sent\." behind */
+                    && strcmp(p+strlen(p)-strlen("." SENT), "." SENT) != 0 /* 
No "\.Sent$" */
+                  )
+               )
                printf("%s", n_sent);
        else
                list_folder(path);
@@ -1146,6 +1153,7 @@
        size_t  i;
        const   char *p;
        int     has_shared=0;
+       int     flag_new_name_buf;
 
        maildir_listfolders(inbox_pfix, homedir, &folders);
        for (i=0; folders[i]; i++)
@@ -1178,6 +1186,7 @@
                        continue;
 
                p=folders[i];
+               flag_new_name_buf=0;
 
                if (strcmp(p, INBOX) == 0)
                        p=folder_inbox;
@@ -1185,8 +1194,23 @@
                        p=folder_drafts;
                else if (strcmp(p, INBOX "." TRASH) == 0)
                        p=folder_trash;
-               else if (strcmp(p, INBOX "." SENT) == 0)
-                       p=folder_sent;
+               else if (strcmp(p, INBOX "." SENT) == 0
+                       || strncmp(p, INBOX "." SENT ".", strlen(INBOX "." SENT 
".")) == 0)
+               {
+                       char *q;
+
+                       q=malloc(strlen(folder_sent)+strlen(p)-strlen(INBOX "." 
SENT)+1);
+                       strcpy(q, folder_sent);
+                       strcat(q, p+strlen(INBOX "." SENT));
+                       p=q;
+                       /* We must free newly allocated buffer below.
+                        * Although there's a "continue;" below, if the program 
goes here,
+                        * it will NOT meet the "continue;". */
+                       flag_new_name_buf=1;
+               }
+               else if(strncmp(p, INBOX ".", strlen(INBOX ".")) == 0)
+                       p+=strlen(INBOX ".");
+
                if (!p) p=folders[i];
 
                if (strncmp(folders[i], SHARED ".", sizeof(SHARED)) == 0)
@@ -1222,10 +1246,9 @@
                        printf("%s.", getarg("PUBLICFOLDERS"));
                }
 
-               p=strchr(folders[i], '.');
-
-               list_folder(p ? p+1:folders[i]);
+               list_folder(p);
                printf("</option>\n");
+               if(flag_new_name_buf) free(p);
        }
        maildir_freefolders(&folders);
 }
_______________________________________________
courier-users mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to