From: Sebastian B. <sb...@us...> - 2013-12-10 20:33:33
|
Update of /cvsroot/simplemail/simplemail In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv7091 Modified Files: folder.c Log Message: Imap folders could appear twice. When imap folders were created from the imap account configuration, the presence of imap folders on the 2nd level or beyond could lead to double folders totally disturbing the folder tree if an order file existed (from which the folders are created in the first step, i.e., before the imap config is checked). SimpleMail currently supports only one level of imap folders and maps the subfolders to the 1st level. The workaround that is implemented attempts to load the true imap path from the .config file before the folder is added for an existing directory, in which case the folder normally is not added again. Index: folder.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/folder.c,v retrieving revision 1.187 retrieving revision 1.188 diff -u -d -r1.187 -r1.188 --- folder.c 10 Dec 2013 19:37:21 -0000 1.187 +++ folder.c 10 Dec 2013 20:33:30 -0000 1.188 @@ -1819,6 +1819,40 @@ int read_line(FILE *fh, char *buf); + +/** + * Return the imap path of the folder specified by the path + * by opening the config. + * + * @param folder_path + * @return the imap path or NULL. + */ +static char *folder_config_get_imap_path(char *folder_path) +{ + char buf[256]; + int rc = 0; + FILE *fh; + + sm_snprintf(buf, sizeof(buf), "%s.config", folder_path); + + if ((fh = fopen(buf,"r"))) + { + read_line(fh,buf); + + if (!mystrnicmp("FICO",buf,4)) + { + rc = 1; + while (read_line(fh,buf)) + { + if (!mystrnicmp("IMapPath=",buf,9)) + { + return mystrdup(&buf[9]); + } + } + } + } +} + /****************************************************************** Load the configuration for the folder *******************************************************************/ @@ -4008,7 +4042,17 @@ { if (st->st_mode & S_IFDIR) { - folder_add_imap(f,sm_file_part(buf)); + char *imap_path; + + /* If possible determine the true imap path that is stored in the config */ + if ((imap_path = folder_config_get_imap_path(buf))) + { + folder_add_imap(f, imap_path); + free(imap_path); + } else + { + folder_add_imap(f, sm_file_part(buf)); + } } } } |