changeset 8257:d30f0525d457 HEAD

Some fixes to shared namespace listing code.
author Timo Sirainen <tss@iki.fi>
date Thu, 09 Oct 2008 13:05:52 +0300
parents 6e1d0ae97963
children 7db59981c1a0
files src/lib-storage/index/shared/shared-list.c
diffstat 1 files changed, 13 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/shared/shared-list.c	Thu Oct 09 00:08:34 2008 +0300
+++ b/src/lib-storage/index/shared/shared-list.c	Thu Oct 09 13:05:52 2008 +0300
@@ -118,15 +118,21 @@
 			    const char *ref, const char *pattern)
 {
 	struct mail_namespace *ns;
+	const char *ns_ref, *prefix = list->ns->prefix;
+	unsigned int prefix_len = strlen(prefix);
 
-	if (*ref != '\0' &&
-	    shared_storage_get_namespace(list->ns->storage, &ref, &ns) == 0)
+	if (*ref != '\0' && strncmp(ref, prefix, prefix_len) == 0)
+		ns_ref = ref + prefix_len;
+	else if (*ref == '\0' && strncmp(pattern, prefix, prefix_len) == 0)
+		ns_ref = pattern + prefix_len;
+	else
+		ns_ref = NULL;
+
+	if (ns_ref != NULL &&
+	    shared_storage_get_namespace(list->ns->storage,
+					 &ns_ref, &ns) == 0)
 		return mailbox_list_join_refpattern(ns->list, ref, pattern);
 
-	if (*ref == '\0' &&
-	    shared_storage_get_namespace(list->ns->storage, &pattern, &ns) == 0)
-		return mailbox_list_join_refpattern(ns->list, "", pattern);
-
 	/* fallback to default behavior */
 	if (*ref != '\0')
 		pattern = t_strconcat(ref, pattern, NULL);
@@ -162,7 +168,7 @@
 		(struct shared_mailbox_list_iterate_context *)_ctx;
 
 	i_free(ctx);
-	return -1;
+	return 0;
 }
 
 static int shared_list_set_subscribed(struct mailbox_list *list,