diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ejabberd_app.erl | 14 | ||||
-rw-r--r-- | src/ejabberd_config.erl | 13 | ||||
-rw-r--r-- | src/ejabberd_http.erl | 7 |
3 files changed, 32 insertions, 2 deletions
diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index 3b333b3b..9d127e74 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -56,6 +56,7 @@ start(normal, _Args) -> ejabberd_admin:start(), gen_mod:start(), ext_mod:start(), + setup_if_elixir_conf_used(), ejabberd_config:start(), set_settings_from_config(), acl:start(), @@ -76,6 +77,7 @@ start(normal, _Args) -> gen_mod:start_modules(), ejabberd_listener:start_listeners(), ejabberd_service:start(), + register_elixir_config_hooks(), ?INFO_MSG("ejabberd ~s is started in the node ~p", [?VERSION, node()]), Sup; start(_, _) -> @@ -240,6 +242,18 @@ opt_type(modules) -> end; opt_type(_) -> [cluster_nodes, loglevel, modules, net_ticktime]. +setup_if_elixir_conf_used() -> + case ejabberd_config:is_using_elixir_config() of + true -> 'Elixir.Ejabberd.Config.Store':start_link(); + false -> ok + end. + +register_elixir_config_hooks() -> + case ejabberd_config:is_using_elixir_config() of + true -> 'Elixir.Ejabberd.Config':start_hooks(); + false -> ok + end. + start_elixir_application() -> case application:ensure_started(elixir) of ok -> ok; diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index b75883fb..7d5dfbc0 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -33,6 +33,7 @@ get_option/2, get_option/3, add_option/2, has_option/1, get_vh_by_auth_method/1, is_file_readable/1, get_version/0, get_myhosts/0, get_mylang/0, + get_ejabberd_config_path/0, is_using_elixir_config/0, prepare_opt_val/4, convert_table_to_binary/5, transform_options/1, collect_options/1, default_db/2, convert_to_yaml/1, convert_to_yaml/2, v_db/2, @@ -147,7 +148,13 @@ read_file(File) -> {include_modules_configs, true}]). read_file(File, Opts) -> - Terms1 = get_plain_terms_file(File, Opts), + Terms1 = case 'Elixir.Ejabberd.ConfigUtil':is_elixir_config(File) of + true -> + 'Elixir.Ejabberd.Config':init(File), + 'Elixir.Ejabberd.Config':get_ejabberd_opts(); + false -> + get_plain_terms_file(File, Opts) + end, Terms_macros = case proplists:get_bool(replace_macros, Opts) of true -> replace_macros(Terms1); false -> Terms1 @@ -1042,6 +1049,10 @@ replace_modules(Modules) -> %% Elixir module naming %% ==================== +is_using_elixir_config() -> + Config = get_ejabberd_config_path(), + 'Elixir.Ejabberd.ConfigUtil':is_elixir_config(Config). + %% If module name start with uppercase letter, this is an Elixir module: is_elixir_module(Module) -> case atom_to_list(Module) of diff --git a/src/ejabberd_http.erl b/src/ejabberd_http.erl index a79f2630..31f80be7 100644 --- a/src/ejabberd_http.erl +++ b/src/ejabberd_http.erl @@ -145,9 +145,14 @@ init({SockMod, Socket}, Opts) -> DefinedHandlers = gen_mod:get_opt( request_handlers, Opts, fun(Hs) -> + Hs1 = lists:map(fun + ({Mod, Path}) when is_atom(Mod) -> {Path, Mod}; + ({Path, Mod}) -> {Path, Mod} + end, Hs), + [{str:tokens( iolist_to_binary(Path), <<"/">>), - Mod} || {Path, Mod} <- Hs] + Mod} || {Path, Mod} <- Hs1] end, []), RequestHandlers = DefinedHandlers ++ Captcha ++ Register ++ Admin ++ Bind ++ XMLRPC, |