From 186e216d1ced120e31c7cde45995827499fc728e Mon Sep 17 00:00:00 2001 From: hiro Date: Fri, 14 Sep 2007 09:04:19 +0000 Subject: check for noinferior and noselect flags when creating a new imap folder. git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@1901 ee746299-78ed-0310-b773-934348b2243d --- libsylph/imap.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) (limited to 'libsylph/imap.c') diff --git a/libsylph/imap.c b/libsylph/imap.c index 35c053e7..cc33ab2a 100644 --- a/libsylph/imap.c +++ b/libsylph/imap.c @@ -2131,6 +2131,7 @@ static FolderItem *imap_create_folder(Folder *folder, FolderItem *parent, gchar separator; gchar *new_name; const gchar *p; + gboolean no_sub = FALSE, no_select = FALSE; gint ok; g_return_val_if_fail(folder != NULL, NULL); @@ -2186,10 +2187,13 @@ static FolderItem *imap_create_folder(Folder *folder, FolderItem *parent, str = g_ptr_array_index(argbuf, i); if (!strncmp(str, "LIST ", 5)) { exist = TRUE; + if (strcasestr(str + 5, "\\Noinferiors")) + no_sub = TRUE; + if (strcasestr(str + 5, "\\Noselect")) + no_select = TRUE; break; } } - g_ptr_array_free(argbuf, TRUE); if (!exist) { ok = imap_cmd_create(session, imap_path); @@ -2199,10 +2203,37 @@ static FolderItem *imap_create_folder(Folder *folder, FolderItem *parent, g_free(dirpath); return NULL; } + + g_ptr_array_free(argbuf, TRUE); + argbuf = g_ptr_array_new(); + ok = imap_cmd_list(session, NULL, imap_path, argbuf); + if (ok != IMAP_SUCCESS) { + log_warning("LIST failed\n"); + g_free(imap_path); + g_free(dirpath); + g_ptr_array_free(argbuf, TRUE); + return NULL; + } + + for (i = 0; i < argbuf->len; i++) { + gchar *str; + str = g_ptr_array_index(argbuf, i); + if (!strncmp(str, "LIST ", 5)) { + if (strcasestr(str + 5, "\\Noinferiors")) + no_sub = TRUE; + if (strcasestr(str + 5, "\\Noselect")) + no_select = TRUE; + break; + } + } } + + g_ptr_array_free(argbuf, TRUE); } new_item = folder_item_new(new_name, dirpath); + new_item->no_sub = no_sub; + new_item->no_select = no_select; folder_item_append(parent, new_item); g_free(imap_path); g_free(dirpath); -- cgit v1.2.3