diff --git a/src/mod_adhoc.erl b/src/mod_adhoc.erl index 3075366c43d..8a76e2bfc0a 100644 --- a/src/mod_adhoc.erl +++ b/src/mod_adhoc.erl @@ -42,49 +42,20 @@ -include_lib("xmpp/include/xmpp.hrl"). -include("translate.hrl"). -start(Host, _Opts) -> - gen_iq_handler:add_iq_handler(ejabberd_local, Host, - ?NS_COMMANDS, ?MODULE, process_local_iq), - gen_iq_handler:add_iq_handler(ejabberd_sm, Host, - ?NS_COMMANDS, ?MODULE, process_sm_iq), - ejabberd_hooks:add(disco_local_identity, Host, ?MODULE, - get_local_identity, 99), - ejabberd_hooks:add(disco_local_features, Host, ?MODULE, - get_local_features, 99), - ejabberd_hooks:add(disco_local_items, Host, ?MODULE, - get_local_commands, 99), - ejabberd_hooks:add(disco_sm_identity, Host, ?MODULE, - get_sm_identity, 99), - ejabberd_hooks:add(disco_sm_features, Host, ?MODULE, - get_sm_features, 99), - ejabberd_hooks:add(disco_sm_items, Host, ?MODULE, - get_sm_commands, 99), - ejabberd_hooks:add(adhoc_local_items, Host, ?MODULE, - ping_item, 100), - ejabberd_hooks:add(adhoc_local_commands, Host, ?MODULE, - ping_command, 100). +start(_Host, _Opts) -> + {ok, [{iq_handler, ejabberd_local, ?NS_COMMANDS, process_local_iq}, + {iq_handler, ejabberd_sm, ?NS_COMMANDS, process_sm_iq}, + {hook, disco_local_identity, get_local_identity, 99}, + {hook, disco_local_features, get_local_features, 99}, + {hook, disco_local_items, get_local_commands, 99}, + {hook, disco_sm_identity, get_sm_identity, 99}, + {hook, disco_sm_features, get_sm_features, 99}, + {hook, disco_sm_items, get_sm_commands, 99}, + {hook, adhoc_local_items, ping_item, 100}, + {hook, adhoc_local_commands, ping_command, 100}]}. -stop(Host) -> - ejabberd_hooks:delete(adhoc_local_commands, Host, - ?MODULE, ping_command, 100), - ejabberd_hooks:delete(adhoc_local_items, Host, ?MODULE, - ping_item, 100), - ejabberd_hooks:delete(disco_sm_items, Host, ?MODULE, - get_sm_commands, 99), - ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE, - get_sm_features, 99), - ejabberd_hooks:delete(disco_sm_identity, Host, ?MODULE, - get_sm_identity, 99), - ejabberd_hooks:delete(disco_local_items, Host, ?MODULE, - get_local_commands, 99), - ejabberd_hooks:delete(disco_local_features, Host, - ?MODULE, get_local_features, 99), - ejabberd_hooks:delete(disco_local_identity, Host, - ?MODULE, get_local_identity, 99), - gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, - ?NS_COMMANDS), - gen_iq_handler:remove_iq_handler(ejabberd_local, Host, - ?NS_COMMANDS). +stop(_Host) -> + ok. reload(_Host, _NewOpts, _OldOpts) -> ok. diff --git a/src/mod_avatar.erl b/src/mod_avatar.erl index 58b4a8af6d6..ae7e74ff0ef 100644 --- a/src/mod_avatar.erl +++ b/src/mod_avatar.erl @@ -43,23 +43,14 @@ %%%=================================================================== %%% API %%%=================================================================== -start(Host, _Opts) -> - ejabberd_hooks:add(pubsub_publish_item, Host, ?MODULE, - pubsub_publish_item, 50), - ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE, - vcard_iq_convert, 30), - ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE, - vcard_iq_publish, 100), - ejabberd_hooks:add(disco_sm_features, Host, ?MODULE, - get_sm_features, 50). +start(_Host, _Opts) -> + {ok, [{hook, pubsub_publish_item, pubsub_publish_item, 50}, + {hook, vcard_iq_set, vcard_iq_convert, 30}, + {hook, vcard_iq_set, vcard_iq_publish, 100}, + {hook, disco_sm_features, get_sm_features, 50}]}. -stop(Host) -> - ejabberd_hooks:delete(pubsub_publish_item, Host, ?MODULE, - pubsub_publish_item, 50), - ejabberd_hooks:delete(vcard_iq_set, Host, ?MODULE, vcard_iq_convert, 30), - ejabberd_hooks:delete(vcard_iq_set, Host, ?MODULE, vcard_iq_publish, 100), - ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE, - get_sm_features, 50). +stop(_Host) -> + ok. reload(_Host, _NewOpts, _OldOpts) -> ok. diff --git a/src/mod_block_strangers.erl b/src/mod_block_strangers.erl index 8595b4aa091..7859e02914f 100644 --- a/src/mod_block_strangers.erl +++ b/src/mod_block_strangers.erl @@ -45,21 +45,13 @@ %%%=================================================================== %%% Callbacks and hooks %%%=================================================================== -start(Host, _Opts) -> - ejabberd_hooks:add(user_receive_packet, Host, - ?MODULE, filter_packet, 25), - ejabberd_hooks:add(roster_in_subscription, Host, - ?MODULE, filter_subscription, 25), - ejabberd_hooks:add(offline_message_hook, Host, - ?MODULE, filter_offline_msg, 25). +start(_Host, _Opts) -> + {ok, [{hook, user_receive_packet, filter_packet, 25}, + {hook, roster_in_subscription, filter_subscription, 25}, + {hook, offline_message_hook, filter_offline_msg, 25}]}. -stop(Host) -> - ejabberd_hooks:delete(user_receive_packet, Host, - ?MODULE, filter_packet, 25), - ejabberd_hooks:delete(roster_in_subscription, Host, - ?MODULE, filter_subscription, 25), - ejabberd_hooks:delete(offline_message_hook, Host, - ?MODULE, filter_offline_msg, 25). +stop(_Host) -> + ok. reload(_Host, _NewOpts, _OldOpts) -> ok. diff --git a/src/mod_blocking.erl b/src/mod_blocking.erl index 75f9aa0b9d4..efc8f6e11ba 100644 --- a/src/mod_blocking.erl +++ b/src/mod_blocking.erl @@ -37,14 +37,12 @@ -include("mod_privacy.hrl"). -include("translate.hrl"). -start(Host, _Opts) -> - ejabberd_hooks:add(disco_local_features, Host, ?MODULE, disco_features, 50), - gen_iq_handler:add_iq_handler(ejabberd_sm, Host, - ?NS_BLOCKING, ?MODULE, process_iq). +start(_Host, _Opts) -> + {ok, [{hook, disco_local_features, disco_features, 50}, + {iq_handler, ejabberd_sm, ?NS_BLOCKING, process_iq}]}. -stop(Host) -> - ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, disco_features, 50), - gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_BLOCKING). +stop(_Host) -> + ok. reload(_Host, _NewOpts, _OldOpts) -> ok. diff --git a/src/mod_carboncopy.erl b/src/mod_carboncopy.erl index c9fe73b0afb..1976e5827be 100644 --- a/src/mod_carboncopy.erl +++ b/src/mod_carboncopy.erl @@ -48,25 +48,18 @@ -type direction() :: sent | received. -type c2s_state() :: ejabberd_c2s:state(). -start(Host, _Opts) -> - ejabberd_hooks:add(disco_local_features, Host, ?MODULE, disco_features, 50), - %% why priority 89: to define clearly that we must run BEFORE mod_logdb hook (90) - ejabberd_hooks:add(user_send_packet,Host, ?MODULE, user_send_packet, 89), - ejabberd_hooks:add(user_receive_packet,Host, ?MODULE, user_receive_packet, 89), - ejabberd_hooks:add(c2s_copy_session, Host, ?MODULE, c2s_copy_session, 50), - ejabberd_hooks:add(c2s_session_resumed, Host, ?MODULE, c2s_session_resumed, 50), - ejabberd_hooks:add(c2s_session_opened, Host, ?MODULE, c2s_session_opened, 50), - gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_CARBONS_2, ?MODULE, iq_handler). +start(_Host, _Opts) -> + {ok, [{hook, disco_local_features, disco_features, 50}, + %% why priority 89: to define clearly that we must run BEFORE mod_logdb hook (90) + {hook, user_send_packet, user_send_packet, 89}, + {hook, user_receive_packet, user_receive_packet, 89}, + {hook, c2s_copy_session, c2s_copy_session, 50}, + {hook, c2s_session_resumed, c2s_session_resumed, 50}, + {hook, c2s_session_opened, c2s_session_opened, 50}, + {iq_handler, ejabberd_sm, ?NS_CARBONS_2, iq_handler}]}. -stop(Host) -> - gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_CARBONS_2), - ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, disco_features, 50), - %% why priority 89: to define clearly that we must run BEFORE mod_logdb hook (90) - ejabberd_hooks:delete(user_send_packet,Host, ?MODULE, user_send_packet, 89), - ejabberd_hooks:delete(user_receive_packet,Host, ?MODULE, user_receive_packet, 89), - ejabberd_hooks:delete(c2s_copy_session, Host, ?MODULE, c2s_copy_session, 50), - ejabberd_hooks:delete(c2s_session_resumed, Host, ?MODULE, c2s_session_resumed, 50), - ejabberd_hooks:delete(c2s_session_opened, Host, ?MODULE, c2s_session_opened, 50). +stop(_Host) -> + ok. reload(_Host, _NewOpts, _OldOpts) -> ok. diff --git a/src/mod_configure.erl b/src/mod_configure.erl index 3aec8e106d2..a3643957742 100644 --- a/src/mod_configure.erl +++ b/src/mod_configure.erl @@ -44,51 +44,21 @@ -include("translate.hrl"). -include_lib("stdlib/include/ms_transform.hrl"). -start(Host, _Opts) -> - ejabberd_hooks:add(disco_local_items, Host, ?MODULE, - get_local_items, 50), - ejabberd_hooks:add(disco_local_features, Host, ?MODULE, - get_local_features, 50), - ejabberd_hooks:add(disco_local_identity, Host, ?MODULE, - get_local_identity, 50), - ejabberd_hooks:add(disco_sm_items, Host, ?MODULE, - get_sm_items, 50), - ejabberd_hooks:add(disco_sm_features, Host, ?MODULE, - get_sm_features, 50), - ejabberd_hooks:add(disco_sm_identity, Host, ?MODULE, - get_sm_identity, 50), - ejabberd_hooks:add(adhoc_local_items, Host, ?MODULE, - adhoc_local_items, 50), - ejabberd_hooks:add(adhoc_local_commands, Host, ?MODULE, - adhoc_local_commands, 50), - ejabberd_hooks:add(adhoc_sm_items, Host, ?MODULE, - adhoc_sm_items, 50), - ejabberd_hooks:add(adhoc_sm_commands, Host, ?MODULE, - adhoc_sm_commands, 50), +start(_Host, _Opts) -> + {ok, [{hook, disco_local_items, get_local_items, 50}, + {hook, disco_local_features, get_local_features, 50}, + {hook, disco_local_identity, get_local_identity, 50}, + {hook, disco_sm_items, get_sm_items, 50}, + {hook, disco_sm_features, get_sm_features, 50}, + {hook, disco_sm_identity, get_sm_identity, 50}, + {hook, adhoc_local_items, adhoc_local_items, 50}, + {hook, adhoc_local_commands, adhoc_local_commands, 50}, + {hook, adhoc_sm_items, adhoc_sm_items, 50}, + {hook, adhoc_sm_commands, adhoc_sm_commands, 50}]}. + +stop(_Host) -> ok. -stop(Host) -> - ejabberd_hooks:delete(adhoc_sm_commands, Host, ?MODULE, - adhoc_sm_commands, 50), - ejabberd_hooks:delete(adhoc_sm_items, Host, ?MODULE, - adhoc_sm_items, 50), - ejabberd_hooks:delete(adhoc_local_commands, Host, - ?MODULE, adhoc_local_commands, 50), - ejabberd_hooks:delete(adhoc_local_items, Host, ?MODULE, - adhoc_local_items, 50), - ejabberd_hooks:delete(disco_sm_identity, Host, ?MODULE, - get_sm_identity, 50), - ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE, - get_sm_features, 50), - ejabberd_hooks:delete(disco_sm_items, Host, ?MODULE, - get_sm_items, 50), - ejabberd_hooks:delete(disco_local_identity, Host, - ?MODULE, get_local_identity, 50), - ejabberd_hooks:delete(disco_local_features, Host, - ?MODULE, get_local_features, 50), - ejabberd_hooks:delete(disco_local_items, Host, ?MODULE, - get_local_items, 50). - reload(_Host, _NewOpts, _OldOpts) -> ok. diff --git a/src/mod_last.erl b/src/mod_last.erl index be7abd5614e..55cc4365760 100644 --- a/src/mod_last.erl +++ b/src/mod_last.erl @@ -62,32 +62,15 @@ start(Host, Opts) -> Mod = gen_mod:db_mod(Opts, ?MODULE), Mod:init(Host, Opts), init_cache(Mod, Host, Opts), - gen_iq_handler:add_iq_handler(ejabberd_local, Host, - ?NS_LAST, ?MODULE, process_local_iq), - gen_iq_handler:add_iq_handler(ejabberd_sm, Host, - ?NS_LAST, ?MODULE, process_sm_iq), - ejabberd_hooks:add(privacy_check_packet, Host, ?MODULE, - privacy_check_packet, 30), - ejabberd_hooks:add(register_user, Host, ?MODULE, - register_user, 50), - ejabberd_hooks:add(remove_user, Host, ?MODULE, - remove_user, 50), - ejabberd_hooks:add(unset_presence_hook, Host, ?MODULE, - on_presence_update, 50). - -stop(Host) -> - ejabberd_hooks:delete(register_user, Host, ?MODULE, - register_user, 50), - ejabberd_hooks:delete(remove_user, Host, ?MODULE, - remove_user, 50), - ejabberd_hooks:delete(unset_presence_hook, Host, - ?MODULE, on_presence_update, 50), - ejabberd_hooks:delete(privacy_check_packet, Host, ?MODULE, - privacy_check_packet, 30), - gen_iq_handler:remove_iq_handler(ejabberd_local, Host, - ?NS_LAST), - gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, - ?NS_LAST). + {ok, [{iq_handler, ejabberd_local, ?NS_LAST, process_local_iq}, + {iq_handler, ejabberd_sm, ?NS_LAST, process_sm_iq}, + {hook, privacy_check_packet, privacy_check_packet, 30}, + {hook, register_user, register_user, 50}, + {hook, remove_user, remove_user, 50}, + {hook, unset_presence_hook, on_presence_update, 50}]}. + +stop(_Host) -> + ok. reload(Host, NewOpts, OldOpts) -> NewMod = gen_mod:db_mod(NewOpts, ?MODULE), diff --git a/src/mod_legacy_auth.erl b/src/mod_legacy_auth.erl index 98daa18ad4e..57f659decc9 100644 --- a/src/mod_legacy_auth.erl +++ b/src/mod_legacy_auth.erl @@ -37,17 +37,12 @@ %%%=================================================================== %%% API %%%=================================================================== -start(Host, _Opts) -> - ejabberd_hooks:add(c2s_unauthenticated_packet, Host, ?MODULE, - c2s_unauthenticated_packet, 50), - ejabberd_hooks:add(c2s_pre_auth_features, Host, ?MODULE, - c2s_stream_features, 50). - -stop(Host) -> - ejabberd_hooks:delete(c2s_unauthenticated_packet, Host, ?MODULE, - c2s_unauthenticated_packet, 50), - ejabberd_hooks:delete(c2s_pre_auth_features, Host, ?MODULE, - c2s_stream_features, 50). +start(_Host, _Opts) -> + {ok, [{hook, c2s_unauthenticated_packet, c2s_unauthenticated_packet, 50}, + {hook, c2s_pre_auth_features, c2s_stream_features, 50}]}. + +stop(_Host) -> + ok. reload(_Host, _NewOpts, _OldOpts) -> ok. diff --git a/src/mod_metrics.erl b/src/mod_metrics.erl index e3dd397f754..38822bef50f 100644 --- a/src/mod_metrics.erl +++ b/src/mod_metrics.erl @@ -49,27 +49,19 @@ %% API %%==================================================================== -start(Host, _Opts) -> - ejabberd_hooks:add(offline_message_hook, Host, ?MODULE, offline_message_hook, 20), - ejabberd_hooks:add(sm_register_connection_hook, Host, ?MODULE, sm_register_connection_hook, 20), - ejabberd_hooks:add(sm_remove_connection_hook, Host, ?MODULE, sm_remove_connection_hook, 20), - ejabberd_hooks:add(user_send_packet, Host, ?MODULE, user_send_packet, 20), - ejabberd_hooks:add(user_receive_packet, Host, ?MODULE, user_receive_packet, 20), - ejabberd_hooks:add(s2s_send_packet, Host, ?MODULE, s2s_send_packet, 20), - ejabberd_hooks:add(s2s_receive_packet, Host, ?MODULE, s2s_receive_packet, 20), - ejabberd_hooks:add(remove_user, Host, ?MODULE, remove_user, 20), - ejabberd_hooks:add(register_user, Host, ?MODULE, register_user, 20). - -stop(Host) -> - ejabberd_hooks:delete(offline_message_hook, Host, ?MODULE, offline_message_hook, 20), - ejabberd_hooks:delete(sm_register_connection_hook, Host, ?MODULE, sm_register_connection_hook, 20), - ejabberd_hooks:delete(sm_remove_connection_hook, Host, ?MODULE, sm_remove_connection_hook, 20), - ejabberd_hooks:delete(user_send_packet, Host, ?MODULE, user_send_packet, 20), - ejabberd_hooks:delete(user_receive_packet, Host, ?MODULE, user_receive_packet, 20), - ejabberd_hooks:delete(s2s_send_packet, Host, ?MODULE, s2s_send_packet, 20), - ejabberd_hooks:delete(s2s_receive_packet, Host, ?MODULE, s2s_receive_packet, 20), - ejabberd_hooks:delete(remove_user, Host, ?MODULE, remove_user, 20), - ejabberd_hooks:delete(register_user, Host, ?MODULE, register_user, 20). +start(_Host, _Opts) -> + {ok, [{hook, offline_message_hook, offline_message_hook, 20}, + {hook, sm_register_connection_hook, sm_register_connection_hook, 20}, + {hook, sm_remove_connection_hook, sm_remove_connection_hook, 20}, + {hook, user_send_packet, user_send_packet, 20}, + {hook, user_receive_packet, user_receive_packet, 20}, + {hook, s2s_send_packet, s2s_send_packet, 20}, + {hook, s2s_receive_packet, s2s_receive_packet, 20}, + {hook, remove_user, remove_user, 20}, + {hook, register_user, register_user, 20}]}. + +stop(_Host) -> + ok. reload(_Host, _NewOpts, _OldOpts) -> ok. diff --git a/src/mod_mqtt_bridge.erl b/src/mod_mqtt_bridge.erl index 4cf8a58919b..74a771d8250 100644 --- a/src/mod_mqtt_bridge.erl +++ b/src/mod_mqtt_bridge.erl @@ -32,13 +32,12 @@ %%%=================================================================== %%% API %%%=================================================================== -start(Host, Opts) -> +start(_Host, Opts) -> User = mod_mqtt_bridge_opt:replication_user(Opts), start_servers(User, element(1, mod_mqtt_bridge_opt:servers(Opts))), - ejabberd_hooks:add(mqtt_publish, Host, ?MODULE, mqtt_publish_hook, 50). + {ok, [{hook, mqtt_publish, mqtt_publish_hook, 50}]}. stop(Host) -> - ejabberd_hooks:delete(mqtt_publish, Host, ?MODULE, mqtt_publish_hook, 50), stop_servers(element(1, mod_mqtt_bridge_opt:servers(Host))), ok. diff --git a/src/mod_offline.erl b/src/mod_offline.erl index 4840ced5f36..d7de2ccd405 100644 --- a/src/mod_offline.erl +++ b/src/mod_offline.erl @@ -120,51 +120,23 @@ start(Host, Opts) -> Mod = gen_mod:db_mod(Opts, ?MODULE), Mod:init(Host, Opts), init_cache(Mod, Host, Opts), - ejabberd_hooks:add(offline_message_hook, Host, ?MODULE, - store_packet, 50), - ejabberd_hooks:add(c2s_self_presence, Host, ?MODULE, c2s_self_presence, 50), - ejabberd_hooks:add(remove_user, Host, - ?MODULE, remove_user, 50), - ejabberd_hooks:add(disco_sm_features, Host, - ?MODULE, get_sm_features, 50), - ejabberd_hooks:add(disco_local_features, Host, - ?MODULE, get_sm_features, 50), - ejabberd_hooks:add(disco_sm_identity, Host, - ?MODULE, get_sm_identity, 50), - ejabberd_hooks:add(disco_sm_items, Host, - ?MODULE, get_sm_items, 50), - ejabberd_hooks:add(disco_info, Host, ?MODULE, get_info, 50), - ejabberd_hooks:add(c2s_handle_info, Host, ?MODULE, c2s_handle_info, 50), - ejabberd_hooks:add(c2s_copy_session, Host, ?MODULE, c2s_copy_session, 50), - ejabberd_hooks:add(webadmin_page_host, Host, - ?MODULE, webadmin_page, 50), - ejabberd_hooks:add(webadmin_user, Host, - ?MODULE, webadmin_user, 50), - ejabberd_hooks:add(webadmin_user_parse_query, Host, - ?MODULE, webadmin_user_parse_query, 50), - gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_FLEX_OFFLINE, - ?MODULE, handle_offline_query). - -stop(Host) -> - ejabberd_hooks:delete(offline_message_hook, Host, - ?MODULE, store_packet, 50), - ejabberd_hooks:delete(c2s_self_presence, Host, ?MODULE, c2s_self_presence, 50), - ejabberd_hooks:delete(remove_user, Host, ?MODULE, - remove_user, 50), - ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE, get_sm_features, 50), - ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, get_sm_features, 50), - ejabberd_hooks:delete(disco_sm_identity, Host, ?MODULE, get_sm_identity, 50), - ejabberd_hooks:delete(disco_sm_items, Host, ?MODULE, get_sm_items, 50), - ejabberd_hooks:delete(disco_info, Host, ?MODULE, get_info, 50), - ejabberd_hooks:delete(c2s_handle_info, Host, ?MODULE, c2s_handle_info, 50), - ejabberd_hooks:delete(c2s_copy_session, Host, ?MODULE, c2s_copy_session, 50), - ejabberd_hooks:delete(webadmin_page_host, Host, - ?MODULE, webadmin_page, 50), - ejabberd_hooks:delete(webadmin_user, Host, - ?MODULE, webadmin_user, 50), - ejabberd_hooks:delete(webadmin_user_parse_query, Host, - ?MODULE, webadmin_user_parse_query, 50), - gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_FLEX_OFFLINE). + {ok, [{hook, offline_message_hook, store_packet, 50}, + {hook, c2s_self_presence, c2s_self_presence, 50}, + {hook, remove_user, remove_user, 50}, + {hook, disco_sm_features, get_sm_features, 50}, + {hook, disco_local_features, get_sm_features, 50}, + {hook, disco_sm_identity, get_sm_identity, 50}, + {hook, disco_sm_items, get_sm_items, 50}, + {hook, disco_info, get_info, 50}, + {hook, c2s_handle_info, c2s_handle_info, 50}, + {hook, c2s_copy_session, c2s_copy_session, 50}, + {hook, webadmin_page_host, webadmin_page, 50}, + {hook, webadmin_user, webadmin_user, 50}, + {hook, webadmin_user_parse_query, webadmin_user_parse_query, 50}, + {iq_handler, ejabberd_sm, ?NS_FLEX_OFFLINE, handle_offline_query}]}. + +stop(_Host) -> + ok. reload(Host, NewOpts, OldOpts) -> NewMod = gen_mod:db_mod(NewOpts, ?MODULE), diff --git a/src/mod_pres_counter.erl b/src/mod_pres_counter.erl index 7359260bc33..04319d1c252 100644 --- a/src/mod_pres_counter.erl +++ b/src/mod_pres_counter.erl @@ -37,14 +37,10 @@ -record(pres_counter, {dir, start, count, logged = false}). -start(Host, _Opts) -> - ejabberd_hooks:add(privacy_check_packet, Host, ?MODULE, - check_packet, 25), - ok. +start(_Host, _Opts) -> + {ok, [{hook, privacy_check_packet, check_packet, 25}]}. -stop(Host) -> - ejabberd_hooks:delete(privacy_check_packet, Host, - ?MODULE, check_packet, 25), +stop(_Host) -> ok. reload(_Host, _NewOpts, _OldOpts) -> diff --git a/src/mod_privacy.erl b/src/mod_privacy.erl index 37f1eb8bccd..25717cadb9d 100644 --- a/src/mod_privacy.erl +++ b/src/mod_privacy.erl @@ -73,32 +73,15 @@ start(Host, Opts) -> Mod = gen_mod:db_mod(Opts, ?MODULE), Mod:init(Host, Opts), init_cache(Mod, Host, Opts), - ejabberd_hooks:add(disco_local_features, Host, ?MODULE, - disco_features, 50), - ejabberd_hooks:add(c2s_copy_session, Host, ?MODULE, - c2s_copy_session, 50), - ejabberd_hooks:add(user_send_packet, Host, ?MODULE, - user_send_packet, 50), - ejabberd_hooks:add(privacy_check_packet, Host, ?MODULE, - check_packet, 50), - ejabberd_hooks:add(remove_user, Host, ?MODULE, - remove_user, 50), - gen_iq_handler:add_iq_handler(ejabberd_sm, Host, - ?NS_PRIVACY, ?MODULE, process_iq). - -stop(Host) -> - ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, - disco_features, 50), - ejabberd_hooks:delete(c2s_copy_session, Host, ?MODULE, - c2s_copy_session, 50), - ejabberd_hooks:delete(user_send_packet, Host, ?MODULE, - user_send_packet, 50), - ejabberd_hooks:delete(privacy_check_packet, Host, - ?MODULE, check_packet, 50), - ejabberd_hooks:delete(remove_user, Host, ?MODULE, - remove_user, 50), - gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, - ?NS_PRIVACY). + {ok, [{hook, disco_local_features, disco_features, 50}, + {hook, c2s_copy_session, c2s_copy_session, 50}, + {hook, user_send_packet, user_send_packet, 50}, + {hook, privacy_check_packet, check_packet, 50}, + {hook, remove_user, remove_user, 50}, + {iq_handler, ejabberd_sm, ?NS_PRIVACY, process_iq}]}. + +stop(_Host) -> + ok. reload(Host, NewOpts, OldOpts) -> NewMod = gen_mod:db_mod(NewOpts, ?MODULE), diff --git a/src/mod_private.erl b/src/mod_private.erl index 52768291da0..d5e252669bf 100644 --- a/src/mod_private.erl +++ b/src/mod_private.erl @@ -62,17 +62,13 @@ start(Host, Opts) -> Mod = gen_mod:db_mod(Opts, ?MODULE), Mod:init(Host, Opts), init_cache(Mod, Host, Opts), - ejabberd_hooks:add(remove_user, Host, ?MODULE, remove_user, 50), - ejabberd_hooks:add(disco_sm_features, Host, ?MODULE, get_sm_features, 50), - ejabberd_hooks:add(pubsub_publish_item, Host, ?MODULE, pubsub_publish_item, 50), - gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PRIVATE, ?MODULE, process_sm_iq), - ejabberd_commands:register_commands(?MODULE, get_commands_spec()). + ejabberd_commands:register_commands(?MODULE, get_commands_spec()), + {ok, [{hook, remove_user, remove_user, 50}, + {hook, disco_sm_features, get_sm_features, 50}, + {hook, pubsub_publish_item, pubsub_publish_item, 50}, + {iq_handler, ejabberd_sm, ?NS_PRIVATE, process_sm_iq}]}. stop(Host) -> - ejabberd_hooks:delete(remove_user, Host, ?MODULE, remove_user, 50), - ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE, get_sm_features, 50), - ejabberd_hooks:delete(pubsub_publish_item, Host, ?MODULE, pubsub_publish_item, 50), - gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_PRIVATE), case gen_mod:is_loaded_elsewhere(Host, ?MODULE) of false -> ejabberd_commands:unregister_commands(get_commands_spec()); diff --git a/src/mod_register.erl b/src/mod_register.erl index 7b05d4fff7d..c7edb66dfff 100644 --- a/src/mod_register.erl +++ b/src/mod_register.erl @@ -43,29 +43,17 @@ -include_lib("xmpp/include/xmpp.hrl"). -include("translate.hrl"). -start(Host, _Opts) -> - gen_iq_handler:add_iq_handler(ejabberd_local, Host, - ?NS_REGISTER, ?MODULE, process_iq), - gen_iq_handler:add_iq_handler(ejabberd_sm, Host, - ?NS_REGISTER, ?MODULE, process_iq), - ejabberd_hooks:add(c2s_pre_auth_features, Host, ?MODULE, - stream_feature_register, 50), - ejabberd_hooks:add(c2s_unauthenticated_packet, Host, - ?MODULE, c2s_unauthenticated_packet, 50), +start(_Host, _Opts) -> ejabberd_mnesia:create(?MODULE, mod_register_ip, [{ram_copies, [node()]}, {local_content, true}, {attributes, [key, value]}]), - ok. + {ok, [{iq_handler, ejabberd_local, ?NS_REGISTER, process_iq}, + {iq_handler, ejabberd_sm, ?NS_REGISTER, process_iq}, + {hook, c2s_pre_auth_features, stream_feature_register, 50}, + {hook, c2s_unauthenticated_packet, c2s_unauthenticated_packet, 50}]}. -stop(Host) -> - ejabberd_hooks:delete(c2s_pre_auth_features, Host, - ?MODULE, stream_feature_register, 50), - ejabberd_hooks:delete(c2s_unauthenticated_packet, Host, - ?MODULE, c2s_unauthenticated_packet, 50), - gen_iq_handler:remove_iq_handler(ejabberd_local, Host, - ?NS_REGISTER), - gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, - ?NS_REGISTER). +stop(_Host) -> + ok. reload(_Host, _NewOpts, _OldOpts) -> ok. diff --git a/src/mod_roster.erl b/src/mod_roster.erl index 892c6cc30fb..ad5fc0f779a 100644 --- a/src/mod_roster.erl +++ b/src/mod_roster.erl @@ -91,48 +91,19 @@ start(Host, Opts) -> Mod = gen_mod:db_mod(Opts, ?MODULE), Mod:init(Host, Opts), init_cache(Mod, Host, Opts), - ejabberd_hooks:add(roster_get, Host, ?MODULE, - get_user_roster_items, 50), - ejabberd_hooks:add(roster_in_subscription, Host, - ?MODULE, in_subscription, 50), - ejabberd_hooks:add(roster_out_subscription, Host, - ?MODULE, out_subscription, 50), - ejabberd_hooks:add(roster_get_jid_info, Host, ?MODULE, - get_jid_info, 50), - ejabberd_hooks:add(remove_user, Host, ?MODULE, - remove_user, 50), - ejabberd_hooks:add(c2s_self_presence, Host, ?MODULE, - c2s_self_presence, 50), - ejabberd_hooks:add(c2s_post_auth_features, Host, - ?MODULE, get_versioning_feature, 50), - ejabberd_hooks:add(webadmin_page_host, Host, ?MODULE, - webadmin_page, 50), - ejabberd_hooks:add(webadmin_user, Host, ?MODULE, - webadmin_user, 50), - gen_iq_handler:add_iq_handler(ejabberd_sm, Host, - ?NS_ROSTER, ?MODULE, process_iq). - -stop(Host) -> - ejabberd_hooks:delete(roster_get, Host, ?MODULE, - get_user_roster_items, 50), - ejabberd_hooks:delete(roster_in_subscription, Host, - ?MODULE, in_subscription, 50), - ejabberd_hooks:delete(roster_out_subscription, Host, - ?MODULE, out_subscription, 50), - ejabberd_hooks:delete(roster_get_jid_info, Host, - ?MODULE, get_jid_info, 50), - ejabberd_hooks:delete(remove_user, Host, ?MODULE, - remove_user, 50), - ejabberd_hooks:delete(c2s_self_presence, Host, ?MODULE, - c2s_self_presence, 50), - ejabberd_hooks:delete(c2s_post_auth_features, - Host, ?MODULE, get_versioning_feature, 50), - ejabberd_hooks:delete(webadmin_page_host, Host, ?MODULE, - webadmin_page, 50), - ejabberd_hooks:delete(webadmin_user, Host, ?MODULE, - webadmin_user, 50), - gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, - ?NS_ROSTER). + {ok, [{hook, roster_get, get_user_roster_items, 50}, + {hook, roster_in_subscription, in_subscription, 50}, + {hook, roster_out_subscription, out_subscription, 50}, + {hook, roster_get_jid_info, get_jid_info, 50}, + {hook, remove_user, remove_user, 50}, + {hook, c2s_self_presence, c2s_self_presence, 50}, + {hook, c2s_post_auth_features, get_versioning_feature, 50}, + {hook, webadmin_page_host, webadmin_page, 50}, + {hook, webadmin_user, webadmin_user, 50}, + {iq_handler, ejabberd_sm, ?NS_ROSTER, process_iq}]}. + +stop(_Host) -> + ok. reload(Host, NewOpts, OldOpts) -> NewMod = gen_mod:db_mod(NewOpts, ?MODULE), diff --git a/src/mod_s2s_dialback.erl b/src/mod_s2s_dialback.erl index cd0a9b8f6fe..527388d8788 100644 --- a/src/mod_s2s_dialback.erl +++ b/src/mod_s2s_dialback.erl @@ -40,49 +40,21 @@ %%%=================================================================== %%% API %%%=================================================================== -start(Host, _Opts) -> - ejabberd_hooks:add(s2s_out_init, Host, ?MODULE, s2s_out_init, 50), - ejabberd_hooks:add(s2s_out_closed, Host, ?MODULE, s2s_out_closed, 50), - ejabberd_hooks:add(s2s_in_pre_auth_features, Host, ?MODULE, - s2s_in_features, 50), - ejabberd_hooks:add(s2s_in_post_auth_features, Host, ?MODULE, - s2s_in_features, 50), - ejabberd_hooks:add(s2s_in_handle_recv, Host, ?MODULE, - s2s_in_recv, 50), - ejabberd_hooks:add(s2s_in_unauthenticated_packet, Host, ?MODULE, - s2s_in_packet, 50), - ejabberd_hooks:add(s2s_in_authenticated_packet, Host, ?MODULE, - s2s_in_packet, 50), - ejabberd_hooks:add(s2s_out_packet, Host, ?MODULE, - s2s_out_packet, 50), - ejabberd_hooks:add(s2s_out_downgraded, Host, ?MODULE, - s2s_out_downgraded, 50), - ejabberd_hooks:add(s2s_out_auth_result, Host, ?MODULE, - s2s_out_auth_result, 50), - ejabberd_hooks:add(s2s_out_tls_verify, Host, ?MODULE, - s2s_out_tls_verify, 50). +start(_Host, _Opts) -> + {ok, [{hook, s2s_out_init, s2s_out_init, 50}, + {hook, s2s_out_closed, s2s_out_closed, 50}, + {hook, s2s_in_pre_auth_features, s2s_in_features, 50}, + {hook, s2s_in_post_auth_features, s2s_in_features, 50}, + {hook, s2s_in_handle_recv, s2s_in_recv, 50}, + {hook, s2s_in_unauthenticated_packet, s2s_in_packet, 50}, + {hook, s2s_in_authenticated_packet, s2s_in_packet, 50}, + {hook, s2s_out_packet, s2s_out_packet, 50}, + {hook, s2s_out_downgraded, s2s_out_downgraded, 50}, + {hook, s2s_out_auth_result, s2s_out_auth_result, 50}, + {hook, s2s_out_tls_verify, s2s_out_tls_verify, 50}]}. -stop(Host) -> - ejabberd_hooks:delete(s2s_out_init, Host, ?MODULE, s2s_out_init, 50), - ejabberd_hooks:delete(s2s_out_closed, Host, ?MODULE, s2s_out_closed, 50), - ejabberd_hooks:delete(s2s_in_pre_auth_features, Host, ?MODULE, - s2s_in_features, 50), - ejabberd_hooks:delete(s2s_in_post_auth_features, Host, ?MODULE, - s2s_in_features, 50), - ejabberd_hooks:delete(s2s_in_handle_recv, Host, ?MODULE, - s2s_in_recv, 50), - ejabberd_hooks:delete(s2s_in_unauthenticated_packet, Host, ?MODULE, - s2s_in_packet, 50), - ejabberd_hooks:delete(s2s_in_authenticated_packet, Host, ?MODULE, - s2s_in_packet, 50), - ejabberd_hooks:delete(s2s_out_packet, Host, ?MODULE, - s2s_out_packet, 50), - ejabberd_hooks:delete(s2s_out_downgraded, Host, ?MODULE, - s2s_out_downgraded, 50), - ejabberd_hooks:delete(s2s_out_auth_result, Host, ?MODULE, - s2s_out_auth_result, 50), - ejabberd_hooks:delete(s2s_out_tls_verify, Host, ?MODULE, - s2s_out_tls_verify, 50). +stop(_Host) -> + ok. reload(_Host, _NewOpts, _OldOpts) -> ok. diff --git a/src/mod_service_log.erl b/src/mod_service_log.erl index c387ce04c65..b7686b693b4 100644 --- a/src/mod_service_log.erl +++ b/src/mod_service_log.erl @@ -36,18 +36,11 @@ -include("translate.hrl"). -include_lib("xmpp/include/xmpp.hrl"). -start(Host, _Opts) -> - ejabberd_hooks:add(user_send_packet, Host, ?MODULE, - log_user_send, 50), - ejabberd_hooks:add(user_receive_packet, Host, ?MODULE, - log_user_receive, 50), - ok. +start(_Host, _Opts) -> + {ok, [{hook, user_send_packet, log_user_send, 50}, + {hook, user_receive_packet, log_user_receive, 50}]}. -stop(Host) -> - ejabberd_hooks:delete(user_send_packet, Host, ?MODULE, - log_user_send, 50), - ejabberd_hooks:delete(user_receive_packet, Host, - ?MODULE, log_user_receive, 50), +stop(_Host) -> ok. depends(_Host, _Opts) -> diff --git a/src/mod_shared_roster.erl b/src/mod_shared_roster.erl index 57999273931..9f94086c1c3 100644 --- a/src/mod_shared_roster.erl +++ b/src/mod_shared_roster.erl @@ -85,53 +85,20 @@ start(Host, Opts) -> Mod = gen_mod:db_mod(Opts, ?MODULE), Mod:init(Host, Opts), init_cache(Mod, Host, Opts), - ejabberd_hooks:add(webadmin_menu_host, Host, ?MODULE, - webadmin_menu, 70), - ejabberd_hooks:add(webadmin_page_host, Host, ?MODULE, - webadmin_page, 50), - ejabberd_hooks:add(roster_get, Host, ?MODULE, - get_user_roster, 70), - ejabberd_hooks:add(roster_in_subscription, Host, - ?MODULE, in_subscription, 30), - ejabberd_hooks:add(roster_out_subscription, Host, - ?MODULE, out_subscription, 30), - ejabberd_hooks:add(roster_get_jid_info, Host, ?MODULE, - get_jid_info, 70), - ejabberd_hooks:add(roster_process_item, Host, ?MODULE, - process_item, 50), - ejabberd_hooks:add(c2s_self_presence, Host, ?MODULE, - c2s_self_presence, 50), - ejabberd_hooks:add(unset_presence_hook, Host, ?MODULE, - unset_presence, 50), - ejabberd_hooks:add(register_user, Host, ?MODULE, - register_user, 50), - ejabberd_hooks:add(remove_user, Host, ?MODULE, - remove_user, 50). - -stop(Host) -> - ejabberd_hooks:delete(webadmin_menu_host, Host, ?MODULE, - webadmin_menu, 70), - ejabberd_hooks:delete(webadmin_page_host, Host, ?MODULE, - webadmin_page, 50), - ejabberd_hooks:delete(roster_get, Host, ?MODULE, - get_user_roster, 70), - ejabberd_hooks:delete(roster_in_subscription, Host, - ?MODULE, in_subscription, 30), - ejabberd_hooks:delete(roster_out_subscription, Host, - ?MODULE, out_subscription, 30), - ejabberd_hooks:delete(roster_get_jid_info, Host, - ?MODULE, get_jid_info, 70), - ejabberd_hooks:delete(roster_process_item, Host, - ?MODULE, process_item, 50), - ejabberd_hooks:delete(c2s_self_presence, Host, - ?MODULE, c2s_self_presence, 50), - ejabberd_hooks:delete(unset_presence_hook, Host, - ?MODULE, unset_presence, 50), - ejabberd_hooks:delete(register_user, Host, ?MODULE, - register_user, 50), - ejabberd_hooks:delete(remove_user, Host, ?MODULE, - remove_user, - 50). + {ok, [{hook, webadmin_menu_host, webadmin_menu, 70}, + {hook, webadmin_page_host, webadmin_page, 50}, + {hook, roster_get, get_user_roster, 70}, + {hook, roster_in_subscription, in_subscription, 30}, + {hook, roster_out_subscription, out_subscription, 30}, + {hook, roster_get_jid_info, get_jid_info, 70}, + {hook, roster_process_item, process_item, 50}, + {hook, c2s_self_presence, c2s_self_presence, 50}, + {hook, unset_presence_hook, unset_presence, 50}, + {hook, register_user, register_user, 50}, + {hook, remove_user, remove_user, 50}]}. + +stop(_Host) -> + ok. reload(Host, NewOpts, OldOpts) -> NewMod = gen_mod:db_mod(NewOpts, ?MODULE), diff --git a/src/mod_sic.erl b/src/mod_sic.erl index 94f82e10be9..0079caf51e3 100644 --- a/src/mod_sic.erl +++ b/src/mod_sic.erl @@ -38,21 +38,14 @@ -include_lib("xmpp/include/xmpp.hrl"). -include("translate.hrl"). -start(Host, _Opts) -> - gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_SIC_0, - ?MODULE, process_local_iq), - gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_SIC_0, - ?MODULE, process_sm_iq), - gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_SIC_1, - ?MODULE, process_local_iq), - gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_SIC_1, - ?MODULE, process_sm_iq). +start(_Host, _Opts) -> + {ok, [{iq_handler, ejabberd_local, ?NS_SIC_0, process_local_iq}, + {iq_handler, ejabberd_sm, ?NS_SIC_0, process_sm_iq}, + {iq_handler, ejabberd_local, ?NS_SIC_1, process_local_iq}, + {iq_handler, ejabberd_sm, ?NS_SIC_1, process_sm_iq}]}. -stop(Host) -> - gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_SIC_0), - gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_SIC_0), - gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_SIC_1), - gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_SIC_1). +stop(_Host) -> + ok. reload(_Host, _NewOpts, _OldOpts) -> ok. diff --git a/src/mod_stats.erl b/src/mod_stats.erl index 492a486b987..216c25f8bc9 100644 --- a/src/mod_stats.erl +++ b/src/mod_stats.erl @@ -38,15 +38,14 @@ -include_lib("xmpp/include/xmpp.hrl"). -include("translate.hrl"). -start(Host, _Opts) -> - gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_STATS, - ?MODULE, process_iq). +start(_Host, _Opts) -> + {ok, [{iq_handler, ejabberd_local, ?NS_STATS, process_iq}]}. -stop(Host) -> - gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_STATS). +stop(_Host) -> + ok. reload(Host, NewOpts, _OldOpts) -> - start(Host, NewOpts). + ok. depends(_Host, _Opts) -> []. diff --git a/src/mod_stream_mgmt.erl b/src/mod_stream_mgmt.erl index 7b02b2e48fa..e87109a5ff4 100644 --- a/src/mod_stream_mgmt.erl +++ b/src/mod_stream_mgmt.erl @@ -61,42 +61,22 @@ %%%=================================================================== %%% API %%%=================================================================== -start(Host, Opts) -> +start(_Host, Opts) -> init_cache(Opts), - ejabberd_hooks:add(c2s_stream_started, Host, ?MODULE, - c2s_stream_started, 50), - ejabberd_hooks:add(c2s_post_auth_features, Host, ?MODULE, - c2s_stream_features, 50), - ejabberd_hooks:add(c2s_unauthenticated_packet, Host, ?MODULE, - c2s_unauthenticated_packet, 50), - ejabberd_hooks:add(c2s_unbinded_packet, Host, ?MODULE, - c2s_unbinded_packet, 50), - ejabberd_hooks:add(c2s_authenticated_packet, Host, ?MODULE, - c2s_authenticated_packet, 50), - ejabberd_hooks:add(c2s_handle_send, Host, ?MODULE, c2s_handle_send, 50), - ejabberd_hooks:add(c2s_handle_recv, Host, ?MODULE, c2s_handle_recv, 50), - ejabberd_hooks:add(c2s_handle_info, Host, ?MODULE, c2s_handle_info, 50), - ejabberd_hooks:add(c2s_handle_call, Host, ?MODULE, c2s_handle_call, 50), - ejabberd_hooks:add(c2s_closed, Host, ?MODULE, c2s_closed, 50), - ejabberd_hooks:add(c2s_terminated, Host, ?MODULE, c2s_terminated, 50). - -stop(Host) -> - ejabberd_hooks:delete(c2s_stream_started, Host, ?MODULE, - c2s_stream_started, 50), - ejabberd_hooks:delete(c2s_post_auth_features, Host, ?MODULE, - c2s_stream_features, 50), - ejabberd_hooks:delete(c2s_unauthenticated_packet, Host, ?MODULE, - c2s_unauthenticated_packet, 50), - ejabberd_hooks:delete(c2s_unbinded_packet, Host, ?MODULE, - c2s_unbinded_packet, 50), - ejabberd_hooks:delete(c2s_authenticated_packet, Host, ?MODULE, - c2s_authenticated_packet, 50), - ejabberd_hooks:delete(c2s_handle_send, Host, ?MODULE, c2s_handle_send, 50), - ejabberd_hooks:delete(c2s_handle_recv, Host, ?MODULE, c2s_handle_recv, 50), - ejabberd_hooks:delete(c2s_handle_info, Host, ?MODULE, c2s_handle_info, 50), - ejabberd_hooks:delete(c2s_handle_call, Host, ?MODULE, c2s_handle_call, 50), - ejabberd_hooks:delete(c2s_closed, Host, ?MODULE, c2s_closed, 50), - ejabberd_hooks:delete(c2s_terminated, Host, ?MODULE, c2s_terminated, 50). + {ok, [{hook, c2s_stream_started, c2s_stream_started, 50}, + {hook, c2s_post_auth_features, c2s_stream_features, 50}, + {hook, c2s_unauthenticated_packet, c2s_unauthenticated_packet, 50}, + {hook, c2s_unbinded_packet, c2s_unbinded_packet, 50}, + {hook, c2s_authenticated_packet, c2s_authenticated_packet, 50}, + {hook, c2s_handle_send, c2s_handle_send, 50}, + {hook, c2s_handle_recv, c2s_handle_recv, 50}, + {hook, c2s_handle_info, c2s_handle_info, 50}, + {hook, c2s_handle_call, c2s_handle_call, 50}, + {hook, c2s_closed, c2s_closed, 50}, + {hook, c2s_terminated, c2s_terminated, 50}]}. + +stop(_Host) -> + ok. reload(_Host, NewOpts, _OldOpts) -> init_cache(NewOpts), diff --git a/src/mod_time.erl b/src/mod_time.erl index c954761c297..9e580e3040f 100644 --- a/src/mod_time.erl +++ b/src/mod_time.erl @@ -39,13 +39,11 @@ -include_lib("xmpp/include/xmpp.hrl"). -include("translate.hrl"). -start(Host, _Opts) -> - gen_iq_handler:add_iq_handler(ejabberd_local, Host, - ?NS_TIME, ?MODULE, process_local_iq). +start(_Host, _Opts) -> + {ok, [{iq_handler, ejabberd_local, ?NS_TIME, process_local_iq}]}. -stop(Host) -> - gen_iq_handler:remove_iq_handler(ejabberd_local, Host, - ?NS_TIME). +stop(_Host) -> + ok. reload(_Host, _NewOpts, _OldOpts) -> ok. diff --git a/src/mod_vcard_xupdate.erl b/src/mod_vcard_xupdate.erl index d169b78f483..3cf67ad090e 100644 --- a/src/mod_vcard_xupdate.erl +++ b/src/mod_vcard_xupdate.erl @@ -48,22 +48,13 @@ start(Host, Opts) -> init_cache(Host, Opts), - ejabberd_hooks:add(c2s_self_presence, Host, ?MODULE, - update_presence, 100), - ejabberd_hooks:add(user_send_packet, Host, ?MODULE, - user_send_packet, 50), - ejabberd_hooks:add(vcard_iq_set, Host, ?MODULE, vcard_set, - 90), - ejabberd_hooks:add(remove_user, Host, ?MODULE, remove_user, 50). - -stop(Host) -> - ejabberd_hooks:delete(c2s_self_presence, Host, - ?MODULE, update_presence, 100), - ejabberd_hooks:delete(user_send_packet, Host, ?MODULE, - user_send_packet, 50), - ejabberd_hooks:delete(vcard_iq_set, Host, ?MODULE, - vcard_set, 90), - ejabberd_hooks:delete(remove_user, Host, ?MODULE, remove_user, 50). + {ok, [{hook, c2s_self_presence, update_presence, 100}, + {hook, user_send_packet, user_send_packet, 50}, + {hook, vcard_iq_set, vcard_set, 90}, + {hook, remove_user, remove_user, 50}]}. + +stop(_Host) -> + ok. reload(Host, NewOpts, _OldOpts) -> init_cache(Host, NewOpts).