Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2018-01-23 10:54:52 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2018-01-23 10:54:52 +0300
commitba2b650464bd3aae2b6b0f3a3177476360cb6d08 (patch)
tree5d55501f76edcdcfe145ba0c3367a54ea0314e5c /src/mod_echo.erl
parentc0ef054f6fa605219b88d41f2d2bf37c52f08d83 (diff)
Introduce new gen_mod callback: mod_options/1
The callback is supposed to provide known options and their default values, as long as the documentation. Passing default values into get_mod functions is now deprecated: all defaults should be provided by the Mod:mod_options/1 callback.
Diffstat (limited to 'src/mod_echo.erl')
-rw-r--r--src/mod_echo.erl17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/mod_echo.erl b/src/mod_echo.erl
index 04b47e08e..7e8c70cb9 100644
--- a/src/mod_echo.erl
+++ b/src/mod_echo.erl
@@ -36,7 +36,7 @@
-export([init/1, handle_call/3, handle_cast/2,
handle_info/2, terminate/2, code_change/3,
- mod_opt_type/1, depends/2]).
+ mod_opt_type/1, depends/2, mod_options/1]).
-include("ejabberd.hrl").
-include("logger.hrl").
@@ -63,8 +63,10 @@ depends(_Host, _Opts) ->
mod_opt_type(host) -> fun iolist_to_binary/1;
mod_opt_type(hosts) ->
- fun(L) -> lists:map(fun iolist_to_binary/1, L) end;
-mod_opt_type(_) -> [host, hosts].
+ fun(L) -> lists:map(fun iolist_to_binary/1, L) end.
+
+mod_options(_Host) ->
+ [{host, <<"echo.@HOST@">>}, {hosts, []}].
%%====================================================================
%% gen_server callbacks
@@ -79,8 +81,7 @@ mod_opt_type(_) -> [host, hosts].
%%--------------------------------------------------------------------
init([Host, Opts]) ->
process_flag(trap_exit, true),
- Hosts = gen_mod:get_opt_hosts(Host, Opts,
- <<"echo.@HOST@">>),
+ Hosts = gen_mod:get_opt_hosts(Host, Opts),
lists:foreach(
fun(H) ->
ejabberd_router:register_route(H, Host)
@@ -106,10 +107,8 @@ handle_call(stop, _From, State) ->
%% Description: Handling cast messages
%%--------------------------------------------------------------------
handle_cast({reload, Host, NewOpts, OldOpts}, State) ->
- NewMyHosts = gen_mod:get_opt_hosts(Host, NewOpts,
- <<"echo.@HOST@">>),
- OldMyHosts = gen_mod:get_opt_hosts(Host, OldOpts,
- <<"echo.@HOST@">>),
+ NewMyHosts = gen_mod:get_opt_hosts(Host, NewOpts),
+ OldMyHosts = gen_mod:get_opt_hosts(Host, OldOpts),
lists:foreach(
fun(H) ->
ejabberd_router:unregister_route(H)