fts-lucene-plugin.c revision 57a712a4998e4bb0073080232225380cd2cea625
02c335c23bf5fa225a467c19f2c063fb0dc7b8c3Timo Sirainen/* Copyright (c) 2006-2011 Dovecot authors, see the included COPYING file */
2eccb2637d0153bb7f9ad39a70f254cece74342cTimo Sirainenconst char *fts_lucene_plugin_version = DOVECOT_VERSION;
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainenstruct fts_lucene_user_module fts_lucene_user_module =
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen MODULE_CONTEXT_INIT(&mail_user_module_register);
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainenfts_lucene_plugin_init_settings(struct mail_user *user,
2eccb2637d0153bb7f9ad39a70f254cece74342cTimo Sirainen const char *str)
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen const char *const *tmp;
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen for (tmp = t_strsplit_spaces(str, " "); *tmp != NULL; tmp++) {
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen if (strncmp(*tmp, "default_language=", 17) == 0) {
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen } else if (strncmp(*tmp, "textcat_conf=", 13) == 0) {
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen set->textcat_conf = p_strdup(user->pool, *tmp + 13);
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen } else if (strncmp(*tmp, "textcat_dir=", 12) == 0) {
4e8e7a93628b4ed60aaaa47c6f72c1433f21e81dTimo Sirainen set->textcat_dir = p_strdup(user->pool, *tmp + 12);
2d6c6f1d06d6d2e7b2ab0d46f7decdcf1cc80cd6Timo Sirainen i_error("fts_lucene: Invalid setting: %s", *tmp);
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen if (set->textcat_conf != NULL && set->textcat_dir == NULL) {
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen i_error("fts_lucene: textcat_conf set, but textcat_dir unset");
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen if (set->textcat_conf == NULL && set->textcat_dir != NULL) {
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen i_error("fts_lucene: textcat_dir set, but textcat_conf unset");
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen "but Dovecot built without stemmer support");
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen "but Dovecot built without textcat support");
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainenuint32_t fts_lucene_settings_checksum(const struct fts_lucene_settings *set)
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainen /* only the default language change matters */
4e8e7a93628b4ed60aaaa47c6f72c1433f21e81dTimo Sirainenstatic void fts_lucene_mail_user_created(struct mail_user *user)
7877db7b5daad125b6cb3e015574f33871c9a51bTimo Sirainen const char *env;
86bdb644d147a73df85abce4325254d694217a5fTimo Sirainen fuser = p_new(user->pool, struct fts_lucene_user, 1);
86bdb644d147a73df85abce4325254d694217a5fTimo Sirainen env = mail_user_plugin_getenv(user, "fts_lucene");
86bdb644d147a73df85abce4325254d694217a5fTimo Sirainen if (fts_lucene_plugin_init_settings(user, &fuser->set, env) < 0) {
86bdb644d147a73df85abce4325254d694217a5fTimo Sirainen /* invalid settings, disabling */
86bdb644d147a73df85abce4325254d694217a5fTimo Sirainen MODULE_CONTEXT_SET(user, fts_lucene_user_module, fuser);
86bdb644d147a73df85abce4325254d694217a5fTimo Sirainenstatic struct mail_storage_hooks fts_lucene_mail_storage_hooks = {
86bdb644d147a73df85abce4325254d694217a5fTimo Sirainen .mail_user_created = fts_lucene_mail_user_created
ae9691f7ef36d5272d72c90fa51393dfea5dd126Timo Sirainenvoid fts_lucene_plugin_init(struct module *module ATTR_UNUSED)
7877db7b5daad125b6cb3e015574f33871c9a51bTimo Sirainen mail_storage_hooks_add(module, &fts_lucene_mail_storage_hooks);
7877db7b5daad125b6cb3e015574f33871c9a51bTimo Sirainen fts_backend_unregister(fts_backend_lucene.name);
7877db7b5daad125b6cb3e015574f33871c9a51bTimo Sirainen mail_storage_hooks_remove(&fts_lucene_mail_storage_hooks);
7877db7b5daad125b6cb3e015574f33871c9a51bTimo Sirainenconst char *fts_lucene_plugin_dependencies[] = { "fts", NULL };