aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNot Zed <NotZed@Ximian.com>2004-08-24 10:50:09 +0800
committerMichael Zucci <zucchi@src.gnome.org>2004-08-24 10:50:09 +0800
commit461c577dbd5e64cfca68a680b40e27ea34bf1861 (patch)
tree62bee3d07f4893a660be41532dccb8d30385bdf3
parent00114b3eb81b3c21fd35664f70a5fb961e7f5e2a (diff)
downloadgsoc2013-evolution-461c577dbd5e64cfca68a680b40e27ea34bf1861.tar.gz
gsoc2013-evolution-461c577dbd5e64cfca68a680b40e27ea34bf1861.tar.zst
gsoc2013-evolution-461c577dbd5e64cfca68a680b40e27ea34bf1861.zip
** See bug #63189.
2004-08-23 Not Zed <NotZed@Ximian.com> ** See bug #63189. * providers/imap/camel-imap-store.c (get_subscribed_folders): only LSUB folders we're interested in, and check full name of each path element. (imap_is_subfolder): helper for above. svn path=/trunk/; revision=27001
-rw-r--r--camel/ChangeLog9
-rw-r--r--camel/providers/imap/camel-imap-store.c33
2 files changed, 38 insertions, 4 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 79ac49748d..1677cfbb20 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,12 @@
+2004-08-23 Not Zed <NotZed@Ximian.com>
+
+ ** See bug #63189.
+
+ * providers/imap/camel-imap-store.c (get_subscribed_folders): only
+ LSUB folders we're interested in, and check full name of each path
+ element.
+ (imap_is_subfolder): helper for above.
+
2004-08-23 Jeffrey Stedfast <fejj@novell.com>
* camel-tcp-stream-openssl.c (open_ssl_connection): Call
diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c
index e87e334a65..4ba85ef39b 100644
--- a/camel/providers/imap/camel-imap-store.c
+++ b/camel/providers/imap/camel-imap-store.c
@@ -2435,12 +2435,36 @@ parse_list_response_as_folder_info (CamelImapStore *imap_store,
return fi;
}
+/* returns true if full_name is a sub-folder of top, or is top */
+static int
+imap_is_subfolder(const char *full_name, const char *top)
+{
+ size_t len = strlen(top);
+
+ /* Looks for top being a full-path subset of full_name.
+ Handle IMAP Inbox case insensitively */
+
+ if (g_ascii_strncasecmp(top, "inbox", 5) == 0
+ && (top[5] == 0 || top[5] == '/')
+ && g_ascii_strncasecmp(full_name, "inbox", 5) == 0
+ && (full_name[5] == 0 || full_name[5] == '/')) {
+ full_name += 5;
+ top += 5;
+ len -= 5;
+ }
+
+ return top[0] == 0
+ || (strncmp(full_name, top, len) == 0
+ && (full_name[len] == 0
+ || full_name[len] == '/'));
+}
+
/* this is used when lsub doesn't provide very useful information */
static GPtrArray *
get_subscribed_folders (CamelImapStore *imap_store, const char *top, CamelException *ex)
{
GPtrArray *names, *folders;
- int i, toplen = strlen (top);
+ int i;
CamelStoreInfo *si;
CamelImapResponse *response;
CamelFolderInfo *fi;
@@ -2453,7 +2477,8 @@ get_subscribed_folders (CamelImapStore *imap_store, const char *top, CamelExcept
folders = g_ptr_array_new ();
names = g_ptr_array_new ();
for (i=0;(si = camel_store_summary_index((CamelStoreSummary *)imap_store->summary, i));i++) {
- if (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) {
+ if (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED
+ && imap_is_subfolder(camel_store_info_path(imap_store->summary, si), top)) {
g_ptr_array_add(names, (char *)camel_imap_store_info_full_name(imap_store->summary, si));
haveinbox = haveinbox || strcasecmp(camel_imap_store_info_full_name(imap_store->summary, si), "INBOX") == 0;
}
@@ -2482,8 +2507,8 @@ get_subscribed_folders (CamelImapStore *imap_store, const char *top, CamelExcept
g_free (result);
if (!fi)
continue;
-
- if (strncmp (top, fi->full_name, toplen) != 0) {
+
+ if (!imap_is_subfolder(fi->full_name, top)) {
camel_folder_info_free (fi);
continue;
}