]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Some fixes to shared namespace listing code.
authorTimo Sirainen <tss@iki.fi>
Thu, 9 Oct 2008 10:05:52 +0000 (13:05 +0300)
committerTimo Sirainen <tss@iki.fi>
Thu, 9 Oct 2008 10:05:52 +0000 (13:05 +0300)
--HG--
branch : HEAD

src/lib-storage/index/shared/shared-list.c

index 2c6871af33604eba086556ebfc549e6800ac9c3e..147cabe1975e67f8bea037cfd98e0393802f3a6c 100644 (file)
@@ -118,14 +118,20 @@ shared_list_join_refpattern(struct mailbox_list *list,
                            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)
-               return mailbox_list_join_refpattern(ns->list, ref, pattern);
+       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 (*ref == '\0' &&
-           shared_storage_get_namespace(list->ns->storage, &pattern, &ns) == 0)
-               return mailbox_list_join_refpattern(ns->list, "", pattern);
+       if (ns_ref != NULL &&
+           shared_storage_get_namespace(list->ns->storage,
+                                        &ns_ref, &ns) == 0)
+               return mailbox_list_join_refpattern(ns->list, ref, pattern);
 
        /* fallback to default behavior */
        if (*ref != '\0')
@@ -162,7 +168,7 @@ static int shared_list_iter_deinit(struct mailbox_list_iterate_context *_ctx)
                (struct shared_mailbox_list_iterate_context *)_ctx;
 
        i_free(ctx);
-       return -1;
+       return 0;
 }
 
 static int shared_list_set_subscribed(struct mailbox_list *list,