From 78dc69fa2263624ab3554fa7107e444a8eb406e1 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 23 Jun 2000 19:51:48 +0000 Subject: [PATCH] providers/imap/camel-imap-[store,folder].c: Improved folder parsing --- camel/ChangeLog | 7 +++++++ camel/providers/imap/camel-imap-folder.c | 13 ++++++++----- camel/providers/imap/camel-imap-store.c | 4 ++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/camel/ChangeLog b/camel/ChangeLog index 6e800f9..46e9046 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,10 @@ +2000-06-23 Jeffrey Stedfast + + * providers/imap/camel-imap-store.c: + * providers/imap/camel-imap-folder.c: Improved folder parsing. + Not specifying a namespace should no longer list the entire + filesystem. + 2000-06-22 Chris Toshok * providers/nntp/.cvsignore: ignore test-newsrc diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index 6c38eb3..51bab59 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -278,7 +278,7 @@ imap_init (CamelFolder *folder, CamelStore *parent_store, CamelFolder *parent_fo imap_folder->summary = NULL; /* SELECT the IMAP mail spool */ - if (url && url->path && strcmp (folder->full_name, "INBOX")) + if (url && url->path && *(url->path + 1) && strcmp (folder->full_name, "INBOX")) folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name); else folder_path = g_strdup (folder->full_name); @@ -439,7 +439,7 @@ imap_get_message_count (CamelFolder *folder, CamelException *ex) if (imap_folder->count != -1) return imap_folder->count; - if (url && url->path && strcmp (folder->full_name, "INBOX")) + if (url && url->path && *(url->path + 1) && strcmp (folder->full_name, "INBOX")) folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name); else folder_path = g_strdup (folder->full_name); @@ -503,10 +503,12 @@ imap_append_message (CamelFolder *folder, CamelMimeMessage *message, CamelExcept } mem->buffer = g_byte_array_append (mem->buffer, g_strdup("\r\n"), 3); - if (url && url->path && strcmp(folder->full_name, "INBOX")) + + if (url && url->path && *(url->path + 1) && strcmp(folder->full_name, "INBOX")) folder_path = g_strdup_printf ("%s/%s", url->path, folder->full_name); else folder_path = g_strdup (folder->full_name); + status = camel_imap_command (CAMEL_IMAP_STORE (folder->parent_store), folder, &result, "APPEND %s (\\Seen) {%d}\r\n%s", @@ -618,7 +620,8 @@ imap_get_subfolder_names (CamelFolder *folder, CamelException *ex) } status = camel_imap_command_extended (CAMEL_IMAP_STORE (folder->parent_store), folder, - &result, "LIST \"\" \"%s/*\"", folder_path); + &result, "LIST \"\" \"%s%s\"", folder_path, + *folder_path ? "/*" : "*"); if (status != CAMEL_IMAP_OK) { CamelService *service = CAMEL_SERVICE (folder->parent_store); @@ -661,7 +664,7 @@ imap_get_subfolder_names (CamelFolder *folder, CamelException *ex) g_free (flags); /* chop out the folder prefix */ - if (!strncmp (folder, folder_path, strlen (folder_path))) { + if (*folder_path && !strncmp (folder, folder_path, strlen (folder_path))) { f = folder + strlen (folder_path) + 1; memmove (folder, f, strlen (f) + 1); } diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index 8635014..f178ad8 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -325,7 +325,7 @@ imap_folder_exists (CamelFolder *folder) gchar *result, *folder_path; gint status; - if (url && url->path && strcmp (folder->full_name, "INBOX")) + if (url && url->path && *(url->path + 1) && strcmp (folder->full_name, "INBOX")) folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name); else folder_path = g_strdup (folder->full_name); @@ -367,7 +367,7 @@ imap_create (CamelFolder *folder, CamelException *ex) return TRUE; /* create the directory for the subfolder */ - if (url && url->path && strcmp (folder->full_name, "INBOX")) + if (url && url->path && *(url->path + 1) && strcmp (folder->full_name, "INBOX")) folder_path = g_strdup_printf ("%s/%s", url->path + 1, folder->full_name); else folder_path = g_strdup (folder->full_name); -- 2.7.4