1
/* Copyright (c) 2008-2012 Dovecot authors, see the included COPYING file */
1
/* Copyright (c) 2008-2013 Dovecot authors, see the included COPYING file */
4
4
#include "imap-match.h"
5
#include "mailbox-tree.h"
5
6
#include "mailbox-list-private.h"
6
7
#include "index-storage.h"
7
8
#include "shared-storage.h"
45
46
name = mailbox_list_get_storage_name(*list, vname);
47
if (*name == '\0' && (ns->flags & NAMESPACE_FLAG_AUTOCREATED) == 0) {
48
/* trying to access the shared/ prefix itself */
49
*storage_r = ns->storage;
46
53
if (shared_storage_get_namespace(&ns, &name) < 0)
49
*storage_r = ns->storage;
54
shared_is_valid_pattern(struct mailbox_list *list, const char *pattern)
56
struct mail_namespace *ns = list->ns;
58
if (shared_storage_get_namespace(&ns, &pattern) < 0)
60
return mailbox_list_is_valid_pattern(ns->list, pattern);
64
shared_is_valid_existing_name(struct mailbox_list *list, const char *name)
66
struct mail_namespace *ns = list->ns;
68
if (shared_storage_get_namespace(&ns, &name) < 0)
70
return mailbox_list_is_valid_existing_name(ns->list, name);
74
shared_is_valid_create_name(struct mailbox_list *list, const char *name)
76
struct mail_namespace *ns = list->ns;
78
if (shared_storage_get_namespace(&ns, &name) < 0)
80
return mailbox_list_is_valid_create_name(ns->list, name);
56
return mailbox_list_get_storage(list, vname, storage_r);
83
59
static char shared_list_get_hierarchy_sep(struct mailbox_list *list ATTR_UNUSED)
89
65
shared_list_get_path(struct mailbox_list *list, const char *name,
90
enum mailbox_list_path_type type)
66
enum mailbox_list_path_type type, const char **path_r)
92
68
struct mail_namespace *ns = list->ns;
94
if (list->ns->storage == NULL || name == NULL ||
70
if (mail_namespace_get_default_storage(list->ns) == NULL ||
95
72
shared_storage_get_namespace(&ns, &name) < 0) {
97
case MAILBOX_LIST_PATH_TYPE_DIR:
98
case MAILBOX_LIST_PATH_TYPE_ALT_DIR:
99
case MAILBOX_LIST_PATH_TYPE_MAILBOX:
100
case MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX:
101
case MAILBOX_LIST_PATH_TYPE_CONTROL:
103
case MAILBOX_LIST_PATH_TYPE_INDEX:
104
/* we can safely say we don't use indexes */
107
73
/* we don't have a directory we can use. */
110
return mailbox_list_get_path(ns->list, name, type);
77
return mailbox_list_get_path(ns->list, name, type, path_r);
113
80
static const char *
134
if (ns_ref != NULL && shared_storage_get_namespace(&ns, &ns_ref) == 0)
101
if (ns_ref != NULL && *ns_ref != '\0' &&
102
shared_storage_get_namespace(&ns, &ns_ref) == 0)
135
103
return mailbox_list_join_refpattern(ns->list, ref, pattern);
137
105
/* fallback to default behavior */
144
112
shared_list_create_missing_namespaces(struct mailbox_list *list,
145
113
const char *const *patterns)
115
struct mail_namespace *ns;
147
116
char sep = mail_namespace_get_sep(list->ns);
148
117
const char *list_pat, *name;
168
137
if (last != NULL) {
169
139
name = t_strdup_until(list_pat, last);
170
(void)mailbox_list_is_valid_existing_name(list, name);
140
(void)shared_storage_get_namespace(&ns, &name);
211
shared_list_subscriptions_refresh(struct mailbox_list *src_list ATTR_UNUSED,
212
struct mailbox_list *dest_list ATTR_UNUSED)
181
shared_list_subscriptions_refresh(struct mailbox_list *src_list,
182
struct mailbox_list *dest_list)
186
if (dest_list->subscriptions == NULL) {
187
sep = mail_namespace_get_sep(src_list->ns);
188
dest_list->subscriptions = mailbox_tree_init(sep);
232
shared_list_create_mailbox_dir(struct mailbox_list *list, const char *name,
233
enum mailbox_dir_create_type type)
235
struct mail_namespace *ns = list->ns;
238
if (shared_storage_get_namespace(&ns, &name) < 0)
240
ret = ns->list->v.create_mailbox_dir(ns->list, name, type);
242
shared_list_copy_error(list, ns);
247
208
shared_list_delete_mailbox(struct mailbox_list *list, const char *name)
249
210
struct mail_namespace *ns = list->ns;
309
270
shared_list_rename_mailbox(struct mailbox_list *oldlist, const char *oldname,
310
struct mailbox_list *newlist, const char *newname,
311
bool rename_children)
271
struct mailbox_list *newlist, const char *newname)
313
273
struct mail_namespace *ns;
317
277
newlist, &newname, &ns) < 0)
320
ret = ns->list->v.rename_mailbox(ns->list, oldname, ns->list, newname,
280
ret = ns->list->v.rename_mailbox(ns->list, oldname, ns->list, newname);
323
282
shared_list_copy_error(oldlist, ns);
333
292
shared_list_alloc,
334
294
shared_list_deinit,
335
295
shared_get_storage,
336
shared_is_valid_pattern,
337
shared_is_valid_existing_name,
338
shared_is_valid_create_name,
339
296
shared_list_get_hierarchy_sep,
340
297
mailbox_list_default_get_vname,
341
298
mailbox_list_default_get_storage_name,
350
307
shared_list_subscriptions_refresh,
351
308
shared_list_set_subscribed,
352
shared_list_create_mailbox_dir,
353
309
shared_list_delete_mailbox,
354
310
shared_list_delete_dir,
355
311
shared_list_delete_symlink,
356
shared_list_rename_mailbox
312
shared_list_rename_mailbox,
313
NULL, NULL, NULL, NULL