Skip to content

Commit

Permalink
global: Use mail_user_plugin_getenv_bool() wherever possible
Browse files Browse the repository at this point in the history
New API is used to check boolean setting OR exsitence of an env variable.
  • Loading branch information
Baofeng Wang authored and GitLab committed May 3, 2016
1 parent 527c2b0 commit 71748cc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/plugins/expire/expire-plugin.c
Expand Up @@ -405,7 +405,7 @@ static void expire_mail_namespaces_created(struct mail_namespace *ns)
struct dict *db;
const char *dict_uri, *error;

if (mail_user_plugin_getenv(user, "expire") == NULL) {
if (!mail_user_plugin_getenv_bool(user, "expire")) {
if (user->mail_debug)
i_debug("expire: No expire setting - plugin disabled");
return;
Expand All @@ -431,7 +431,7 @@ static void expire_mail_namespaces_created(struct mail_namespace *ns)

euser->db = db;
euser->set = expire_set_init(expire_get_patterns(user));
euser->expire_cache = mail_user_plugin_getenv(user, "expire_cache") != NULL;
euser->expire_cache = mail_user_plugin_getenv_bool(user, "expire_cache");
MODULE_CONTEXT_SET(user, expire_mail_user_module, euser);
}

Expand Down
12 changes: 6 additions & 6 deletions src/plugins/fts/fts-storage.c
Expand Up @@ -211,8 +211,8 @@ fts_mailbox_search_init(struct mailbox_transaction_context *t,
fctx->virtual_mailbox =
strcmp(t->box->storage->name, VIRTUAL_STORAGE_NAME) == 0;
fctx->enforced =
mail_user_plugin_getenv(t->box->storage->user,
"fts_enforced") != NULL;
mail_user_plugin_getenv_bool(t->box->storage->user,
"fts_enforced");
i_array_init(&fctx->levels, 8);
fctx->scores = i_new(struct fts_scores, 1);
fctx->scores->refcount = 1;
Expand All @@ -222,8 +222,8 @@ fts_mailbox_search_init(struct mailbox_transaction_context *t,
/* FIXME: we'll assume that all the args are fuzzy. not good,
but would require much more work to fix it. */
if (!fts_args_have_fuzzy(args->args) &&
mail_user_plugin_getenv(t->box->storage->user,
"fts_no_autofuzzy") != NULL)
mail_user_plugin_getenv_bool(t->box->storage->user,
"fts_no_autofuzzy"))
fctx->flags |= FTS_LOOKUP_FLAG_NO_AUTO_FUZZY;
/* transaction contains the last search's scores. they can be
queried later with mail_get_special() */
Expand Down Expand Up @@ -631,8 +631,8 @@ fts_transaction_commit(struct mailbox_transaction_context *t,
int ret = 0;

autoindex = ft->mails_saved &&
mail_user_plugin_getenv(box->storage->user,
"fts_autoindex") != NULL;
mail_user_plugin_getenv_bool(box->storage->user,
"fts_autoindex");

if (fts_transaction_end(t) < 0) {
mail_storage_set_error(t->box->storage, MAIL_ERROR_TEMP,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/lazy-expunge/lazy-expunge-plugin.c
Expand Up @@ -502,7 +502,7 @@ static void lazy_expunge_mail_user_created(struct mail_user *user)
v->deinit = lazy_expunge_user_deinit;
luser->env = env;
luser->copy_only_last_instance =
mail_user_plugin_getenv(user, "lazy_expunge_only_last_instance") != NULL;
mail_user_plugin_getenv_bool(user, "lazy_expunge_only_last_instance");

MODULE_CONTEXT_SET(user, lazy_expunge_mail_user_module, luser);
} else if (user->mail_debug) {
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/pop3-migration/pop3-migration-plugin.c
Expand Up @@ -884,14 +884,14 @@ static void pop3_migration_mail_storage_created(struct mail_storage *storage)

mstorage->pop3_box_vname = p_strdup(storage->pool, pop3_box_vname);
mstorage->all_mailboxes =
mail_user_plugin_getenv(storage->user,
"pop3_migration_all_mailboxes") != NULL;
mail_user_plugin_getenv_bool(storage->user,
"pop3_migration_all_mailboxes");
mstorage->ignore_missing_uidls =
mail_user_plugin_getenv(storage->user,
"pop3_migration_ignore_missing_uidls") != NULL;
mail_user_plugin_getenv_bool(storage->user,
"pop3_migration_ignore_missing_uidls");
mstorage->skip_size_check =
mail_user_plugin_getenv(storage->user,
"pop3_migration_skip_size_check") != NULL;
mail_user_plugin_getenv_bool(storage->user,
"pop3_migration_skip_size_check");

MODULE_CONTEXT_SET(storage, pop3_migration_storage_module, mstorage);
}
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/stats/stats-plugin.c
Expand Up @@ -410,8 +410,7 @@ static void stats_user_created(struct mail_user *user)
v->stats_fill = stats_user_stats_fill;

suser->refresh_secs = refresh_secs;
str = mail_user_plugin_getenv(user, "stats_track_cmds");
if (str != NULL && strcmp(str, "yes") == 0)
if (mail_user_plugin_getenv_bool(user, "stats_track_cmds"))
suser->track_commands = TRUE;

suser->stats_conn = global_stats_conn;
Expand Down

0 comments on commit 71748cc

Please sign in to comment.