mailbox-list.c \
mailbox-list-notify.c \
mailbox-list-register.c \
- mailbox-match-plugin.c \
mailbox-recent-flags.c \
mailbox-search-result.c \
mailbox-tree.c \
mailbox-list-iter.h \
mailbox-list-private.h \
mailbox-list-notify.h \
- mailbox-match-plugin.h \
mailbox-recent-flags.h \
mailbox-search-result-private.h \
mailbox-tree.h \
+++ /dev/null
-/* Copyright (c) 2021 Dovecot authors, see the included COPYING file */
-
-#include "lib.h"
-#include "array.h"
-#include "str.h"
-#include "wildcard-match.h"
-#include "mail-storage-private.h"
-#include "mailbox-match-plugin.h"
-#include "mailbox-list-private.h"
-
-struct mailbox_match_plugin {
- ARRAY_TYPE(const_string) patterns;
-};
-
-struct mailbox_match_plugin *
-mailbox_match_plugin_init(struct mail_user *user, const char *set_prefix)
-{
- struct mailbox_match_plugin *match;
- string_t *str;
- const char *value;
-
- match = i_new(struct mailbox_match_plugin, 1);
-
- value = mail_user_plugin_getenv(user, set_prefix);
- if (value == NULL)
- return match;
-
- i_array_init(&match->patterns, 16);
- str = t_str_new(128);
- for (unsigned int i = 2; value != NULL; i++) {
- /* value points to user's settings, so there's no need to
- strdup() it. */
- array_push_back(&match->patterns, &value);
-
- str_truncate(str, 0);
- str_printfa(str, "%s%u", set_prefix, i);
-
- value = mail_user_plugin_getenv(user, str_c(str));
- }
-
- return match;
-}
-
-bool mailbox_match_plugin_exclude(struct mailbox_match_plugin *match,
- struct mailbox *box)
-{
- const struct mailbox_settings *set;
- const char *const *special_use;
- const char *pattern;
-
- if (!array_is_created(&match->patterns))
- return FALSE;
-
- set = mailbox_get_settings(box);
- special_use = set == NULL ? NULL :
- t_strsplit_spaces(set->special_use, " ");
-
- array_foreach_elem(&match->patterns, pattern) {
- if (pattern[0] == '\\') {
- /* \Special-use flag */
- if (special_use != NULL &&
- str_array_icase_find(special_use, pattern))
- return TRUE;
- } else {
- if (wildcard_match(box->vname, pattern))
- return TRUE;
-
- /* for namespaces with inbox=yes, try to match also without prefix */
- if (HAS_ALL_BITS(box->list->ns->flags, NAMESPACE_FLAG_INBOX_USER) &&
- wildcard_match(box->vname + box->list->ns->prefix_len, pattern))
- return TRUE;
- }
- }
- return FALSE;
-}
-
-void mailbox_match_plugin_deinit(struct mailbox_match_plugin **_match)
-{
- struct mailbox_match_plugin *match = *_match;
-
- if (match == NULL)
- return;
- *_match = NULL;
-
- array_free(&match->patterns);
- i_free(match);
-}
+++ /dev/null
-#ifndef MAILBOX_MATCH_PLUGIN_H
-#define MAILBOX_MATCH_PLUGIN_H
-
-struct mailbox;
-
-/* Utility library to allow a Dovecot plugin an easy way to configure a list
- of mailbox patterns and special-use flags that can be matched against. */
-
-struct mailbox_match_plugin *
-mailbox_match_plugin_init(struct mail_user *user, const char *set_prefix);
-void mailbox_match_plugin_deinit(struct mailbox_match_plugin **match);
-
-bool mailbox_match_plugin_exclude(struct mailbox_match_plugin *match,
- struct mailbox *box);
-
-#endif
union mailbox_module_context module_ctx;
const struct fts_settings *set;
struct fts_backend_update_context *sync_update_ctx;
- bool fts_mailbox_excluded;
};
struct fts_transaction_context {
struct mail_transaction_commit_changes *changes_r)
{
struct mailbox *box = t->box;
- const struct fts_settings *set = fts_user_get_settings(box->storage->user);
struct fts_transaction_context *ft = FTS_CONTEXT_REQUIRE(t);
struct fts_mailbox *fbox = FTS_CONTEXT_REQUIRE(box);
bool autoindex;
int ret = 0;
const char *error;
- autoindex = set->autoindex && ft->mails_saved &&
- !fbox->fts_mailbox_excluded;
+ autoindex = fbox->set->autoindex && ft->mails_saved;
if (fts_transaction_end(t, &error) < 0) {
mail_storage_set_error(t->box->storage, MAIL_ERROR_TEMP,
v->free = fts_mailbox_free;
fbox->set = set;
box->vlast = &fbox->module_ctx.super;
- fbox->fts_mailbox_excluded = fts_user_autoindex_exclude(box);
-
v->get_status = fts_mailbox_get_status;
v->search_init = fts_mailbox_search_init;
v->search_next_nonblock = fts_mailbox_search_next_nonblock;
#include "str-parse.h"
#include "mail-user.h"
#include "mail-storage-private.h"
-#include "mailbox-match-plugin.h"
#include "language.h"
#include "lang-filter.h"
#include "lang-tokenizer.h"
struct language_list *lang_list;
struct fts_user_language *data_lang;
ARRAY_TYPE(fts_user_language) languages, data_languages;
-
- struct mailbox_match_plugin *autoindex_exclude;
};
static MODULE_CONTEXT_DEFINE_INIT(fts_user_module,
return fuser->set;
}
-bool fts_user_autoindex_exclude(struct mailbox *box)
-{
- struct fts_user *fuser = FTS_USER_CONTEXT_REQUIRE(box->storage->user);
-
- return mailbox_match_plugin_exclude(fuser->autoindex_exclude, box);
-}
-
int fts_user_try_get_settings(struct mail_user *user,
const struct fts_settings **set_r)
{
return -1;
}
}
- fuser->autoindex_exclude =
- mailbox_match_plugin_init(user, "fts_autoindex_exclude");
MODULE_CONTEXT_SET(user, fts_user_module, fuser);
return 0;
int fts_user_try_get_settings(struct mail_user *user,
const struct fts_settings **set_r);
-bool fts_user_autoindex_exclude(struct mailbox *box);
size_t fts_mail_user_message_max_size(struct mail_user *user);
int fts_mail_user_init(struct mail_user *user, bool initialize_libfts,