26
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-28 17:38:54 +01:00

Update some modules to the new gen_mod API

This commit is contained in:
Alexey Shchepin 2023-08-04 18:53:50 +03:00
parent 20a8654be2
commit 60002fc145
24 changed files with 200 additions and 517 deletions

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -44,50 +44,20 @@
-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),
ok.
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) ->
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).
stop(_Host) ->
ok.
reload(_Host, _NewOpts, _OldOpts) ->
ok.

View File

@ -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).
{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) ->
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).
stop(_Host) ->
ok.
reload(Host, NewOpts, OldOpts) ->
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),

View File

@ -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).
start(_Host, _Opts) ->
{ok, [{hook, c2s_unauthenticated_packet, c2s_unauthenticated_packet, 50},
{hook, c2s_pre_auth_features, 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).
stop(_Host) ->
ok.
reload(_Host, _NewOpts, _OldOpts) ->
ok.

View File

@ -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).
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) ->
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).
stop(_Host) ->
ok.
reload(_Host, _NewOpts, _OldOpts) ->
ok.

View File

@ -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.

View File

@ -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).
{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) ->
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).
stop(_Host) ->
ok.
reload(Host, NewOpts, OldOpts) ->
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),

View File

@ -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) ->

View File

@ -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).
{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) ->
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).
stop(_Host) ->
ok.
reload(Host, NewOpts, OldOpts) ->
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),

View File

@ -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());

View File

@ -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.

View File

@ -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).
{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) ->
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).
stop(_Host) ->
ok.
reload(Host, NewOpts, OldOpts) ->
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),

View File

@ -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.

View File

@ -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) ->

View File

@ -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).
{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) ->
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).
stop(_Host) ->
ok.
reload(Host, NewOpts, OldOpts) ->
NewMod = gen_mod:db_mod(NewOpts, ?MODULE),

View File

@ -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.

View File

@ -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) ->
[].

View File

@ -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).
{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) ->
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).
stop(_Host) ->
ok.
reload(_Host, NewOpts, _OldOpts) ->
init_cache(NewOpts),

View File

@ -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.

View File

@ -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).
{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) ->
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).
stop(_Host) ->
ok.
reload(Host, NewOpts, _OldOpts) ->
init_cache(Host, NewOpts).