index_storage_mailbox_rename,
index_storage_get_status,
NULL,
+ index_storage_set_subscribed,
index_storage_list_index_has_changed,
index_storage_list_index_update_sync,
cydir_storage_sync_init,
index_storage_mailbox_rename,
index_storage_get_status,
mdbox_mailbox_get_metadata,
+ index_storage_set_subscribed,
index_storage_list_index_has_changed,
index_storage_list_index_update_sync,
mdbox_storage_sync_init,
index_storage_mailbox_rename,
index_storage_get_status,
sdbox_mailbox_get_metadata,
+ index_storage_set_subscribed,
index_storage_list_index_has_changed,
index_storage_list_index_update_sync,
sdbox_storage_sync_init,
index_storage_mailbox_rename,
imapc_mailbox_get_status,
imapc_mailbox_get_metadata,
+ index_storage_set_subscribed,
NULL,
NULL,
imapc_mailbox_sync_init,
}
} T_END;
}
+
+int index_storage_set_subscribed(struct mailbox *box, bool set)
+{
+ struct mail_namespace *ns;
+ struct mailbox_list *list = box->list;
+ const char *subs_name;
+
+ if ((list->ns->flags & NAMESPACE_FLAG_SUBSCRIPTIONS) != 0)
+ subs_name = box->name;
+ else {
+ /* subscriptions=no namespace, find another one where we can
+ add the subscription to */
+ ns = mail_namespace_find_subscribable(list->ns->user->namespaces,
+ box->vname);
+ if (ns == NULL) {
+ mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
+ "This namespace has no subscriptions");
+ return -1;
+ }
+ /* use <orig ns prefix><orig storage name> as the
+ subscription name */
+ subs_name = t_strconcat(list->ns->prefix, box->name, NULL);
+ /* drop the common prefix (typically there isn't one) */
+ i_assert(strncmp(ns->prefix, subs_name, strlen(ns->prefix)) == 0);
+ subs_name += strlen(ns->prefix);
+
+ list = ns->list;
+ }
+ if (mailbox_list_set_subscribed(list, subs_name, set) < 0) {
+ mail_storage_copy_list_error(box->storage, list);
+ return -1;
+ }
+ return 0;
+}
+
void index_save_context_free(struct mail_save_context *ctx);
void index_copy_cache_fields(struct mail_save_context *ctx,
struct mail *src_mail, uint32_t dest_seq);
+int index_storage_set_subscribed(struct mailbox *box, bool set);
bool index_keyword_array_cmp(const ARRAY_TYPE(keyword_indexes) *k1,
const ARRAY_TYPE(keyword_indexes) *k2);
index_storage_mailbox_rename,
index_storage_get_status,
maildir_mailbox_get_metadata,
+ index_storage_set_subscribed,
maildir_list_index_has_changed,
maildir_list_index_update_sync,
maildir_storage_sync_init,
index_storage_mailbox_rename,
index_storage_get_status,
mbox_mailbox_get_metadata,
+ index_storage_set_subscribed,
index_storage_list_index_has_changed,
index_storage_list_index_update_sync,
mbox_storage_sync_init,
index_storage_mailbox_rename,
index_storage_get_status,
index_mailbox_get_metadata,
+ index_storage_set_subscribed,
index_storage_list_index_has_changed,
index_storage_list_index_update_sync,
raw_storage_sync_init,
int (*get_metadata)(struct mailbox *box,
enum mailbox_metadata_items items,
struct mailbox_metadata *metadata_r);
+ int (*set_subscribed)(struct mailbox *box, bool set);
/* Lookup sync extension record and figure out if it mailbox has
changed since. Returns 1 = yes, 0 = no, -1 = error. */
int mailbox_set_subscribed(struct mailbox *box, bool set)
{
- struct mail_namespace *ns;
- struct mailbox_list *list = box->list;
- const char *subs_name;
-
- if (!mailbox_list_is_valid_existing_name(list, box->name)) {
+ if (!mailbox_list_is_valid_existing_name(box->list, box->name)) {
mail_storage_set_error(box->storage, MAIL_ERROR_PARAMS,
"Invalid mailbox name");
return -1;
}
- if ((list->ns->flags & NAMESPACE_FLAG_SUBSCRIPTIONS) != 0)
- subs_name = box->name;
- else {
- /* subscriptions=no namespace, find another one where we can
- add the subscription to */
- ns = mail_namespace_find_subscribable(list->ns->user->namespaces,
- box->vname);
- if (ns == NULL) {
- mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
- "This namespace has no subscriptions");
- return -1;
- }
- /* use <orig ns prefix><orig storage name> as the
- subscription name */
- subs_name = t_strconcat(list->ns->prefix, box->name, NULL);
- /* drop the common prefix (typically there isn't one) */
- i_assert(strncmp(ns->prefix, subs_name, strlen(ns->prefix)) == 0);
- subs_name += strlen(ns->prefix);
-
- list = ns->list;
- }
- if (mailbox_list_set_subscribed(list, subs_name, set) < 0) {
- mail_storage_copy_list_error(box->storage, list);
- return -1;
- }
- return 0;
+ return box->v.set_subscribed(box, set);
}
struct mail_storage *mailbox_get_storage(const struct mailbox *box)
return 0;
}
+static int test_mailbox_set_subscribed(struct mailbox *box,
+ bool set ATTR_UNUSED)
+{
+ mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
+ "Test mailbox subscribing isn't supported");
+ return -1;
+}
+
static struct mailbox_sync_context *
test_mailbox_sync_init(struct mailbox *box,
enum mailbox_sync_flags flags ATTR_UNUSED)
test_mailbox_rename,
test_mailbox_get_status,
NULL,
+ test_mailbox_set_subscribed,
NULL,
NULL,
test_mailbox_sync_init,
index_storage_mailbox_rename,
virtual_storage_get_status,
virtual_mailbox_get_metadata,
+ index_storage_set_subscribed,
NULL,
NULL,
virtual_storage_sync_init,