-callback start(binary(), opts()) -> any().
-callback stop(binary()) -> any().
-callback mod_opt_type(atom()) -> fun((term()) -> term()) | [atom()].
+-callback depends(binary(), opts()) -> [{module(), hard | soft}].
-export_type([opts/0]).
-export_type([db_type/0]).
get_modules_options(Host) ->
ejabberd_config:get_option(
- {modules, Host},
- fun(Mods) ->
- lists:map(
+ {modules, Host},
+ fun(Mods) ->
+ lists:map(
fun({M, A}) when is_atom(M), is_list(A) ->
- {M, A}
+ {M, A}
end, Mods)
- end, []).
+ end, []).
+
+sort_modules(Host, ModOpts) ->
+ G = digraph:new([acyclic]),
+ lists:foreach(
+ fun({Mod, Opts}) ->
+ digraph:add_vertex(G, Mod, Opts),
+ Deps = try Mod:depends(Host, Opts) catch _:undef -> [] end,
+ lists:foreach(
+ fun({DepMod, Type}) ->
+ case lists:keyfind(DepMod, 1, ModOpts) of
+ false when Type == hard ->
+ ErrTxt = io_lib:format(
+ "failed to load module '~s' "
+ "because it depends on module '~s' "
+ "which is not found in the config",
+ [Mod, DepMod]),
+ ?ERROR_MSG(ErrTxt, []),
+ digraph:del_vertex(G, Mod),
+ maybe_halt_ejabberd(ErrTxt);
+ false when Type == soft ->
+ ?WARNING_MSG("module '~s' is recommended for "
+ "module '~s' but is not found in "
+ "the config",
+ [DepMod, Mod]);
+ {DepMod, DepOpts} ->
+ digraph:add_vertex(G, DepMod, DepOpts),
+ digraph:add_edge(G, DepMod, Mod)
+ end
+ end, Deps)
+ end, ModOpts),
+ [digraph:vertex(G, V) || V <- digraph_utils:topsort(G)].
-spec start_modules(binary()) -> any().
start_modules(Host) ->
- Modules = get_modules_options(Host),
+ Modules = sort_modules(Host, get_modules_options(Host)),
lists:foreach(
fun({Module, Opts}) ->
start_module(Host, Module, Opts)
[Module, Host, Opts, Class, Reason,
erlang:get_stacktrace()]),
?CRITICAL_MSG(ErrorText, []),
- case is_app_running(ejabberd) of
- true ->
- erlang:raise(Class, Reason, erlang:get_stacktrace());
- false ->
- ?CRITICAL_MSG("ejabberd initialization was aborted "
- "because a module start failed.",
- []),
- timer:sleep(3000),
- erlang:halt(string:substr(lists:flatten(ErrorText), 1, 199))
- end
+ maybe_halt_ejabberd(ErrorText),
+ erlang:raise(Class, Reason, erlang:get_stacktrace())
+ end.
+
+maybe_halt_ejabberd(ErrorText) ->
+ case is_app_running(ejabberd) of
+ false ->
+ ?CRITICAL_MSG("ejabberd initialization was aborted "
+ "because a module start failed.",
+ []),
+ timer:sleep(3000),
+ erlang:halt(string:substr(lists:flatten(ErrorText), 1, 199));
+ true ->
+ ok
end.
is_app_running(AppName) ->
process_sm_iq/3, get_local_commands/5,
get_local_identity/5, get_local_features/5,
get_sm_commands/5, get_sm_identity/5, get_sm_features/5,
- ping_item/4, ping_command/4, mod_opt_type/1]).
+ ping_item/4, ping_command/4, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
end;
ping_command(Acc, _From, _To, _Request) -> Acc.
+depends(_Host, _Opts) ->
+ [].
+
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
mod_opt_type(report_commands_node) ->
fun (B) when is_boolean(B) -> B end;
srg_delete/2, srg_list/1, srg_get_info/2,
srg_get_members/2, srg_user_add/4, srg_user_del/4,
send_message/5, send_stanza/3, send_stanza_c2s/4, privacy_set/3,
- stats/1, stats/2, mod_opt_type/1, get_commands_spec/0]).
+ stats/1, stats/2, mod_opt_type/1, get_commands_spec/0, depends/2]).
-include("ejabberd.hrl").
stop(_Host) ->
ejabberd_commands:unregister_commands(get_commands_spec()).
+depends(_Host, _Opts) ->
+ [].
%%%
%%% Register commands
-export([start/2, init/0, stop/1, export/1, import/1,
import/3, announce/3, send_motd/1, disco_identity/5,
- disco_features/5, disco_items/5,
+ disco_features/5, disco_items/5, depends/2,
send_announcement_to_all/3, announce_commands/4,
announce_items/4, mod_opt_type/1]).
register(gen_mod:get_module_proc(Host, ?PROCNAME),
proc_lib:spawn(?MODULE, init, [])).
+depends(_Host, _Opts) ->
+ [{mod_adhoc, hard}].
+
init() ->
loop().
-protocol({xep, 191, '1.2'}).
-export([start/2, stop/1, process_iq/3,
- process_iq_set/4, process_iq_get/5, mod_opt_type/1]).
+ process_iq_set/4, process_iq_get/5, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
?NS_BLOCKING).
+depends(_Host, _Opts) ->
+ [{mod_privacy, hard}].
+
process_iq(_From, _To, IQ) ->
SubEl = IQ#iq.sub_el,
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]}.
import_start/2, import_stop/2]).
%% gen_mod callbacks
--export([start/2, start_link/2, stop/1]).
+-export([start/2, start_link/2, stop/1, depends/2]).
%% gen_server callbacks
-export([init/1, handle_info/2, handle_call/3,
end;
c2s_broadcast_recipients(Acc, _, _, _, _, _) -> Acc.
+depends(_Host, _Opts) ->
+ [].
+
init([Host, Opts]) ->
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
Mod:init(Host, Opts),
get_local_features/5, get_local_items/5,
adhoc_local_items/4, adhoc_local_commands/4,
get_sm_identity/5, get_sm_features/5, get_sm_items/5,
- adhoc_sm_items/4, adhoc_sm_commands/4, mod_opt_type/1]).
+ adhoc_sm_items/4, adhoc_sm_commands/4, mod_opt_type/1,
+ depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
?NS_COMMANDS).
+depends(_Host, _Opts) ->
+ [{mod_adhoc, hard}, {mod_last, soft}].
+
%%%-----------------------------------------------------------------------
-define(INFO_IDENTITY(Category, Type, Name, Lang),
-behaviour(gen_mod).
-export([start/2, stop/1, process_local_iq/3,
- mod_opt_type/1, opt_type/1]).
+ mod_opt_type/1, opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
%% {result, };
process_get(_, _) -> {error, ?ERR_BAD_REQUEST}.
+depends(_Host, _Opts) ->
+ [].
+
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
mod_opt_type(_) -> [iqdisc].
get_sm_identity/5, get_sm_features/5, get_sm_items/5,
get_info/5, register_feature/2, unregister_feature/2,
register_extra_domain/2, unregister_extra_domain/2,
- transform_module_options/1, mod_opt_type/1]).
+ transform_module_options/1, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
end,
Values).
+depends(_Host, _Opts) ->
+ [].
+
mod_opt_type(extra_domains) ->
fun (Hs) -> [iolist_to_binary(H) || H <- Hs] end;
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
-export([init/1, handle_call/3, handle_cast/2,
handle_info/2, terminate/2, code_change/3,
- mod_opt_type/1]).
+ mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
?INFO_MSG("Information of the client: ~s~s",
[ToS, Values_string2]).
+depends(_Host, _Opts) ->
+ [].
+
mod_opt_type(host) -> fun iolist_to_binary/1;
mod_opt_type(_) -> [host].
-export([init/1, handle_call/3, handle_cast/2,
handle_info/2, terminate/2, code_change/3,
- mod_opt_type/1]).
+ mod_opt_type/1, depends/2]).
-include_lib("stdlib/include/ms_transform.hrl").
-include("ejabberd.hrl").
supervisor:terminate_child(ejabberd_sup, Proc),
supervisor:delete_child(ejabberd_sup, Proc).
+depends(_Host, _Opts) ->
+ [].
+
%%%===================================================================
%%% gen_server callbacks
%%%===================================================================
-behaviour(gen_mod).
--export([start/2, stop/1, process/2, mod_opt_type/1]).
+-export([start/2, stop/1, process/2, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("jlib.hrl").
stop(_Host) ->
ok.
+depends(_Host, _Opts) ->
+ [].
+
%% ----------
%% basic auth
%% ----------
-behaviour(gen_mod).
--export([start/2, stop/1, process/2, mod_opt_type/1]).
+-export([start/2, stop/1, process/2, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
fun (I) when is_integer(I), I > 0 -> I end;
mod_opt_type(_) -> [max_inactivity, max_pause].
+depends(_Host, _Opts) ->
+ [].
%%%----------------------------------------------------------------------
%%% Help Web Page
%% utility for other http modules
-export([content_type/3]).
--export([reopen_log/1, mod_opt_type/1]).
+-export([reopen_log/1, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
supervisor:terminate_child(ejabberd_sup, Proc),
supervisor:delete_child(ejabberd_sup, Proc).
+depends(_Host, _Opts) ->
+ [].
+
%%====================================================================
%% API
%%====================================================================
-export([start_link/3,
start/2,
stop/1,
+ depends/2,
mod_opt_type/1]).
%% gen_server callbacks.
dir_mode, docroot, put_url, get_url, service_url, custom_headers,
rm_on_unregister, thumbnail].
+-spec depends(binary(), gen_mod:opts()) -> [{module(), hard | soft}].
+
+depends(_Host, _Opts) ->
+ [].
+
%%--------------------------------------------------------------------
%% gen_server callbacks.
%%--------------------------------------------------------------------
-export([start_link/3,
start/2,
stop/1,
+ depends/2,
mod_opt_type/1]).
%% gen_server callbacks.
mod_opt_type(_) ->
[access_soft_quota, access_hard_quota, max_days].
+-spec depends(binary(), gen_mod:opts()) -> [{module(), hard | soft}].
+
+depends(_Host, _Opts) ->
+ [].
+
%%--------------------------------------------------------------------
%% gen_server callbacks.
%%--------------------------------------------------------------------
-export([update_bl_c2s/0]).
--export([is_ip_in_c2s_blacklist/3, mod_opt_type/1]).
+-export([is_ip_in_c2s_blacklist/3, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
error:_ -> Parent ! {ok, Pid, true}
end.
+depends(_Host, _Opts) ->
+ [].
+
%% TODO:
stop(_Host) -> ok.
-export([init/1, handle_call/3, handle_cast/2,
handle_info/2, terminate/2, code_change/3,
- mod_opt_type/1]).
+ mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
gen_server:call(Proc, stop),
supervisor:delete_child(ejabberd_sup, Proc).
+depends(_Host, _Opts) ->
+ [].
+
%%====================================================================
%% gen_server callbacks
%%====================================================================
process_sm_iq/3, on_presence_update/4, import/1,
import/3, store_last_info/4, get_last_info/2,
remove_user/2, transform_options/1, mod_opt_type/1,
- opt_type/1, register_user/2]).
+ opt_type/1, register_user/2, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
transform_options(Opt, Opts) ->
[Opt|Opts].
+depends(_Host, _Opts) ->
+ [].
+
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
mod_opt_type(_) -> [db_type, iqdisc].
-behaviour(gen_mod).
%% API
--export([start/2, stop/1]).
+-export([start/2, stop/1, depends/2]).
-export([user_send_packet/4, user_send_packet_strip_tag/4, user_receive_packet/5,
process_iq_v0_2/3, process_iq_v0_3/3, disco_sm_features/5,
ejabberd_commands:unregister_commands(get_commands_spec()),
ok.
+depends(_Host, _Opts) ->
+ [].
+
remove_user(User, Server) ->
LUser = jid:nodeprep(User),
LServer = jid:nameprep(Server),
s2s_send_packet, s2s_receive_packet,
remove_user, register_user]).
--export([start/2, stop/1, send_metrics/4, opt_type/1, mod_opt_type/1]).
+-export([start/2, stop/1, send_metrics/4, opt_type/1, mod_opt_type/1,
+ depends/2]).
-export([offline_message_hook/3,
sm_register_connection_hook/3, sm_remove_connection_hook/3,
[ejabberd_hooks:delete(Hook, Host, ?MODULE, Hook, 20)
|| Hook <- ?HOOKS].
+depends(_Host, _Opts) ->
+ [].
+
%%====================================================================
%% Hooks handlers
%%====================================================================
%% API
-export([start_link/2, start/2, stop/1, process_iq/3,
disco_items/5, disco_identity/5, disco_info/5,
- disco_features/5, mod_opt_type/1]).
+ disco_features/5, mod_opt_type/1, depends/2]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2,
_ -> false
end.
+depends(_Host, _Opts) ->
+ [{mod_pubsub, hard}].
+
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
mod_opt_type(host) -> fun iolist_to_binary/1;
mod_opt_type(_) -> [host, iqdisc].
-export([init/1, handle_call/3, handle_cast/2,
handle_info/2, terminate/2, code_change/3,
- mod_opt_type/1]).
+ mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
supervisor:delete_child(ejabberd_sup, Proc),
{wait, Rooms}.
+depends(_Host, _Opts) ->
+ [{mod_mam, soft}].
+
shutdown_rooms(Host) ->
MyHost = gen_mod:get_module_opt_host(Host, mod_muc,
<<"conference.@HOST@">>),
-behaviour(gen_mod).
--export([start/2, stop/1, muc_online_rooms/1,
+-export([start/2, stop/1, depends/2, muc_online_rooms/1,
muc_unregister_nick/1, create_room/3, destroy_room/2,
create_rooms_file/1, destroy_rooms_file/1,
rooms_unused_list/2, rooms_unused_destroy/2,
ejabberd_hooks:delete(webadmin_page_main, ?MODULE, web_page_main, 50),
ejabberd_hooks:delete(webadmin_page_host, Host, ?MODULE, web_page_host, 50).
+depends(_Host, _Opts) ->
+ [{mod_muc, hard}].
+
%%%
%%% Register commands
%%%
-export([init/1, handle_call/3, handle_cast/2,
handle_info/2, terminate/2, code_change/3,
- mod_opt_type/1, opt_type/1]).
+ mod_opt_type/1, opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
Opt
end, Opts).
+depends(_Host, _Opts) ->
+ [{mod_muc, hard}].
+
%%====================================================================
%% gen_server callbacks
%%====================================================================
-export([init/1, handle_info/2, handle_call/3,
handle_cast/2, terminate/2, code_change/3]).
--export([purge_loop/1, mod_opt_type/1]).
+-export([purge_loop/1, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
jts(String) -> jid:to_string(String).
+depends(_Host, _Opts) ->
+ [].
+
mod_opt_type(access) ->
fun acl:access_rules_validator/1;
mod_opt_type(host) -> fun iolist_to_binary/1;
-export([init/1, handle_call/3, handle_cast/2,
handle_info/2, terminate/2, code_change/3,
- mod_opt_type/1]).
+ mod_opt_type/1, depends/2]).
-deprecated({get_queue_length,2}).
supervisor:delete_child(ejabberd_sup, Proc),
ok.
+depends(_Host, _Opts) ->
+ [].
%%====================================================================
%% gen_server callbacks
check_packet/6, remove_user/2,
is_list_needdb/1, updated_list/3,
item_to_xml/1, get_user_lists/2, import/3,
- set_privacy_list/1, mod_opt_type/1]).
+ set_privacy_list/1, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
Mod = gen_mod:db_mod(DBType, ?MODULE),
Mod:import(LServer, Data).
+depends(_Host, _Opts) ->
+ [].
+
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
mod_opt_type(_) -> [db_type, iqdisc].
-export([start/2, stop/1, process_sm_iq/3, import/3,
remove_user/2, get_data/2, export/1, import/1,
- mod_opt_type/1, set_data/3]).
+ mod_opt_type/1, set_data/3, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
Mod = gen_mod:db_mod(DBType, ?MODULE),
Mod:import(LServer, PD).
+depends(_Host, _Opts) ->
+ [].
+
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
mod_opt_type(_) -> [db_type, iqdisc].
%% supervisor callbacks.
-export([init/1]).
--export([start_link/2, mod_opt_type/1]).
+-export([start_link/2, mod_opt_type/1, depends/2]).
-define(PROCNAME, ejabberd_mod_proxy65).
{{one_for_one, 10, 1},
[StreamManager, StreamSupervisor, Service]}}.
+depends(_Host, _Opts) ->
+ [].
+
mod_opt_type(auth_type) ->
fun (plain) -> plain;
(anonymous) -> anonymous
%% API and gen_server callbacks
-export([start_link/2, start/2, stop/1, init/1,
handle_call/3, handle_cast/2, handle_info/2,
- terminate/2, code_change/3]).
+ terminate/2, code_change/3, depends/2]).
-export([send_loop/1, mod_opt_type/1]).
end,
{Pid, State}.
+depends(ServerHost, Opts) ->
+ Host = gen_mod:get_opt_host(ServerHost, Opts, <<"pubsub.@HOST@">>),
+ Plugins = gen_mod:get_opt(plugins, Opts,
+ fun(A) when is_list(A) -> A end, [?STDNODE]),
+ lists:flatmap(
+ fun(Name) ->
+ Plugin = plugin(ServerHost, Name),
+ try apply(Plugin, depends, [Host, ServerHost, Opts])
+ catch _:undef -> []
+ end
+ end, Plugins).
+
%% @doc Call the init/1 function for each plugin declared in the config file.
%% The default plugin module is implicit.
%% <p>The Erlang code for the plugin is located in a module called
unauthenticated_iq_register/4, try_register/5,
process_iq/3, send_registration_notifications/3,
transform_options/1, transform_module_options/1,
- mod_opt_type/1, opt_type/1]).
+ mod_opt_type/1, opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
?NS_REGISTER).
+depends(_Host, _Opts) ->
+ [].
+
stream_feature_register(Acc, Host) ->
AF = gen_mod:get_module_opt(Host, ?MODULE, access_from,
fun(A) -> A end,
-behaviour(gen_mod).
--export([start/2, stop/1, process/2, mod_opt_type/1]).
+-export([start/2, stop/1, process/2, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
stop(_Host) -> ok.
+depends(_Host, _Opts) ->
+ [{mod_register, hard}].
+
%%%----------------------------------------------------------------------
%%% HTTP handlers
%%%----------------------------------------------------------------------
get_jid_info/4, item_to_xml/1, webadmin_page/3,
webadmin_user/4, get_versioning_feature/2,
roster_versioning_enabled/1, roster_version/2,
- mod_opt_type/1, set_roster/1]).
+ mod_opt_type/1, set_roster/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
?NS_ROSTER).
+depends(_Host, _Opts) ->
+ [].
+
process_iq(From, To, IQ) when ((From#jid.luser == <<"">>) andalso (From#jid.resource == <<"">>)) ->
process_iq_manager(From, To, IQ);
-behaviour(gen_mod).
-export([start/2, stop/1, log_user_send/4,
- log_user_receive/5, mod_opt_type/1]).
+ log_user_receive/5, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
?MODULE, log_user_receive, 50),
ok.
+depends(_Host, _Opts) ->
+ [].
+
log_user_send(Packet, _C2SState, From, To) ->
log_packet(From, To, Packet, From#jid.lserver),
Packet.
delete_group/2, get_group_opts/2, set_group_opts/3,
get_group_users/2, get_group_explicit_users/2,
is_user_in_group/3, add_user_to_group/3, opts_to_binary/1,
- remove_user_from_group/3, mod_opt_type/1]).
+ remove_user_from_group/3, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
%%ejabberd_hooks:delete(remove_user, Host,
%% ?MODULE, remove_user, 50),
+depends(_Host, _Opts) ->
+ [].
+
get_user_roster(Items, US) ->
{U, S} = US,
DisplayedGroups = get_user_displayed_groups(US),
-export([get_user_roster/2, get_subscription_lists/3,
get_jid_info/4, process_item/2, in_subscription/6,
- out_subscription/4, mod_opt_type/1, opt_type/1]).
+ out_subscription/4, mod_opt_type/1, opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
supervisor:terminate_child(ejabberd_sup, Proc),
supervisor:delete_child(ejabberd_sup, Proc).
+depends(_Host, _Opts) ->
+ [{mod_roster, hard}].
+
%%--------------------------------------------------------------------
%% Hooks
%%--------------------------------------------------------------------
-behaviour(gen_mod).
-export([start/2, stop/1, process_local_iq/3,
- process_sm_iq/3, mod_opt_type/1]).
+ process_sm_iq/3, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
?NS_SIC).
+depends(_Host, _Opts) ->
+ [].
+
process_local_iq(#jid{user = User, server = Server,
resource = Resource},
_To, #iq{type = get, sub_el = _SubEl} = IQ) ->
-export([data_in/2, data_out/2, message_in/2,
message_out/2, request/2, request/3, response/2,
- locate/1, mod_opt_type/1]).
+ locate/1, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
stop(_Host) ->
ok.
+depends(_Host, _Opts) ->
+ [].
+
data_in(Data, #sip_socket{type = Transport,
addr = {MyIP, MyPort},
peer = {PeerIP, PeerPort}}) ->
-behaviour(gen_mod).
-export([start/2, stop/1, process_local_iq/3,
- mod_opt_type/1]).
+ mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
?NS_STATS).
+depends(_Host, _Opts) ->
+ [].
+
process_local_iq(_From, To,
#iq{id = _ID, type = Type, xmlns = XMLNS,
sub_el = SubEl, lang = Lang} =
-behaviour(gen_mod).
-export([start/2, stop/1, process_local_iq/3,
- mod_opt_type/1]).
+ mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
sign(N) when N < 0 -> <<"-">>;
sign(_) -> <<"+">>.
+depends(_Host, _Opts) ->
+ [].
+
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
mod_opt_type(_) -> [iqdisc].
-export([start/2, init/3, stop/1, get_sm_features/5,
process_local_iq/3, process_sm_iq/3, string2lower/1,
- remove_user/2, export/1, import/1, import/3,
+ remove_user/2, export/1, import/1, import/3, depends/2,
mod_opt_type/1, set_vcard/3, make_vcard_search/4]).
-include("ejabberd.hrl").
Mod = gen_mod:db_mod(DBType, ?MODULE),
Mod:import(LServer, VCard).
+depends(_Host, _Opts) ->
+ [].
+
mod_opt_type(allow_return_all) ->
fun (B) when is_boolean(B) -> B end;
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
-export([start/2, start_link/2, stop/1,
get_sm_features/5, process_local_iq/3, process_sm_iq/3,
remove_user/1, route/4, transform_module_options/1,
- mod_opt_type/1, opt_type/1]).
+ mod_opt_type/1, opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
supervisor:terminate_child(ejabberd_sup, Proc),
supervisor:delete_child(ejabberd_sup, Proc).
+depends(_Host, _Opts) ->
+ [].
+
terminate(_Reason, State) ->
Host = State#state.serverhost,
gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
-export([start/2, stop/1]).
-export([update_presence/3, vcard_set/3, export/1,
- import/1, import/3, mod_opt_type/1]).
+ import/1, import/3, mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
vcard_set, 100),
ok.
+depends(_Host, _Opts) ->
+ [].
+
%%====================================================================
%% Hooks
%%====================================================================
-behaviour(gen_mod).
-export([start/2, stop/1, process_local_iq/3,
- mod_opt_type/1]).
+ mod_opt_type/1, depends/2]).
-include("ejabberd.hrl").
-include("logger.hrl").
#xmlel{name = <<"os">>, attrs = [],
children = [{xmlcdata, OS}]}.
+depends(_Host, _Opts) ->
+ [].
+
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
mod_opt_type(show_os) ->
fun (B) when is_boolean(B) -> B end;
get_pending_nodes/2, get_states/1, get_state/2,
set_state/1, get_items/7, get_items/3, get_item/7,
get_item/2, set_item/1, get_item_name/3, node_to_path/1,
- path_to_node/1]).
+ path_to_node/1, depends/3]).
+
+depends(_Host, _ServerHost, _Opts) ->
+ [{mod_caps, hard}].
init(Host, ServerHost, Opts) ->
node_flat:init(Host, ServerHost, Opts),
- complain_if_modcaps_disabled(ServerHost),
ok.
terminate(Host, ServerHost) ->
path_to_node(Path) ->
node_flat:path_to_node(Path).
-
-%%%
-%%% Internal
-%%%
-
-%% @doc Check mod_caps is enabled, otherwise show warning.
-%% The PEP plugin for mod_pubsub requires mod_caps to be enabled in the host.
-%% Check that the mod_caps module is enabled in that Jabber Host
-%% If not, show a warning message in the ejabberd log file.
-complain_if_modcaps_disabled(ServerHost) ->
- case gen_mod:is_loaded(ServerHost, mod_caps) of
- false ->
- ?WARNING_MSG("The PEP plugin is enabled in mod_pubsub "
- "of host ~p. This plugin requires mod_caps "
- "but it does not seems enabled, please check config.",
- [ServerHost]);
- true -> ok
- end.
get_pending_nodes/2, get_states/1, get_state/2,
set_state/1, get_items/7, get_items/3, get_item/7,
get_item/2, set_item/1, get_item_name/3, node_to_path/1,
- path_to_node/1,
+ path_to_node/1, depends/3,
get_entity_subscriptions_for_send_last/2, get_last_items/3]).
+depends(_Host, _ServerHost, _Opts) ->
+ [{mod_caps, hard}].
+
init(Host, ServerHost, Opts) ->
node_flat_sql:init(Host, ServerHost, Opts),
- complain_if_modcaps_disabled(ServerHost),
ok.
terminate(Host, ServerHost) ->
path_to_node(Path) ->
node_flat_sql:path_to_node(Path).
-
-%%%
-%%% Internal
-%%%
-
-%% @doc Check mod_caps is enabled, otherwise show warning.
-%% The PEP plugin for mod_pubsub requires mod_caps to be enabled in the host.
-%% Check that the mod_caps module is enabled in that Jabber Host
-%% If not, show a warning message in the ejabberd log file.
-complain_if_modcaps_disabled(ServerHost) ->
- case gen_mod:is_loaded(ServerHost, mod_caps) of
- false ->
- ?WARNING_MSG("The PEP plugin is enabled in mod_pubsub "
- "of host ~p. This plugin requires mod_caps "
- "to be enabled, but it isn't.",
- [ServerHost]);
- true -> ok
- end.