-define(GEN_SERVER, gen_server).
-endif.
-behaviour(?GEN_SERVER).
+-behaviour(ejabberd_config).
%% API
-export([start_link/3, add_iq_handler/6,
remove_iq_handler/3, stop_iq_handler/3, handle/5,
- process_iq/4, check_type/1, transform_module_options/1]).
+ process_iq/4, check_type/1, transform_module_options/1,
+ opt_type/1, iqdisc/1]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2,
check_type(N) when is_integer(N), N>0 -> N;
check_type(parallel) -> parallel.
+iqdisc(Host) ->
+ ejabberd_config:get_option({iqdisc, Host}, one_queue).
+
-spec transform_module_options([{atom(), any()}]) -> [{atom(), any()}].
transform_module_options(Opts) ->
Opt
end, Opts).
+opt_type(iqdisc) -> fun check_type/1;
+opt_type(_) -> [iqdisc].
+
%%====================================================================
%% gen_server callbacks
%%====================================================================
-include("xmpp.hrl").
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
?NS_COMMANDS, ?MODULE, process_local_iq,
IQDisc),
?NS_COMMANDS).
reload(Host, NewOpts, OldOpts) ->
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_COMMANDS,
?MODULE, process_local_iq, IQDisc),
-type block_event() :: {block, [jid()]} | {unblock, [jid()]} | unblock_all.
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
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, IQDisc).
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_BLOCKING).
reload(Host, NewOpts, OldOpts) ->
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_BLOCKING,
?MODULE, process_iq, IQDisc);
false.
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
ejabberd_hooks:add(disco_local_features, Host, ?MODULE, disco_features, 50),
Mod = gen_mod:ram_db_mod(Host, ?MODULE),
init_cache(Mod, Host, Opts),
false ->
ok
end,
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_CARBONS_2,
?MODULE, iq_handler, IQDisc);
sub_els = [#delegation{delegated = [#delegated{ns = NS}]}]},
Delegations = dict:store({NS, Type}, {Host, Info}, State#state.delegations),
gen_iq_handler:add_iq_handler(Type, State#state.server_host, NS,
- ?MODULE, Type, one_queue),
+ ?MODULE, Type, gen_iq_handler:iqdisc(Host)),
ejabberd_router:route(Msg),
?INFO_MSG("Namespace '~s' is delegated to external component '~s'",
[NS, Host]),
-type items_acc() :: {error, stanza_error()} | {result, [disco_item()]} | empty.
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
?NS_DISCO_ITEMS, ?MODULE,
process_local_iq_items, IQDisc),
true ->
ok
end,
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
?NS_DISCO_ITEMS, ?MODULE,
catch ets:new(irc_connection,
[named_table, public,
{keypos, #irc_connection.jid_server_host}]),
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
register_hooks(MyHost, IQDisc),
ejabberd_router:register_route(MyHost, Host),
{ok,
handle_cast({reload, ServerHost, NewOpts, OldOpts}, State) ->
NewHost = gen_mod:get_opt_host(ServerHost, NewOpts, <<"irc.@HOST@">>),
OldHost = gen_mod:get_opt_host(ServerHost, OldOpts, <<"irc.@HOST@">>),
- NewIQDisc = gen_mod:get_opt(iqdisc, NewOpts, one_queue),
- OldIQDisc = gen_mod:get_opt(iqdisc, OldOpts, one_queue),
+ NewIQDisc = gen_mod:get_opt(iqdisc, NewOpts, gen_iq_handler:iqdisc(ServerHost)),
+ OldIQDisc = gen_mod:get_opt(iqdisc, OldOpts, gen_iq_handler:iqdisc(ServerHost)),
NewMod = gen_mod:db_mod(ServerHost, NewOpts, ?MODULE),
OldMod = gen_mod:db_mod(ServerHost, OldOpts, ?MODULE),
Access = gen_mod:get_opt(access, NewOpts, all),
-callback remove_user(binary(), binary()) -> any().
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
Mod:init(Host, Opts),
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
true ->
ok
end,
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_LAST,
?MODULE, process_local_iq, IQDisc),
%%% API
%%%===================================================================
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
Mod:init(Host, Opts),
init_cache(Host, Opts),
ok
end,
ets_cache:setopts(archive_prefs_cache, NewOpts),
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
register_iq_handlers(Host, IQDisc);
true ->
init([ServerHost, Opts]) ->
process_flag(trap_exit, true),
Host = gen_mod:get_opt_host(ServerHost, Opts, <<"mix.@HOST@">>),
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
ConfigTab = gen_mod:get_module_proc(Host, config),
ets:new(ConfigTab, [named_table]),
ets:insert(ConfigTab, {plugins, [<<"mix">>]}),
init([Host, Opts]) ->
process_flag(trap_exit, true),
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
#state{access = Access, host = MyHost,
history_size = HistorySize, queue_type = QueueType,
room_shaper = RoomShaper} = State = init_state(Host, Opts),
{reply, ok, State}.
handle_cast({reload, ServerHost, NewOpts, OldOpts}, #state{host = OldHost}) ->
- NewIQDisc = gen_mod:get_opt(iqdisc, NewOpts, one_queue),
- OldIQDisc = gen_mod:get_opt(iqdisc, OldOpts, one_queue),
+ NewIQDisc = gen_mod:get_opt(iqdisc, NewOpts, gen_iq_handler:iqdisc(ServerHost)),
+ OldIQDisc = gen_mod:get_opt(iqdisc, OldOpts, gen_iq_handler:iqdisc(ServerHost)),
NewMod = gen_mod:db_mod(ServerHost, NewOpts, ?MODULE),
NewRMod = gen_mod:ram_db_mod(ServerHost, NewOpts, ?MODULE),
OldMod = gen_mod:db_mod(ServerHost, OldOpts, ?MODULE),
process_flag(trap_exit, true),
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
Mod:init(Host, Opts),
- IQDisc = gen_mod:get_opt(iqdisc, Opts, no_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
ejabberd_hooks:add(offline_message_hook, Host, ?MODULE,
store_packet, 50),
ejabberd_hooks:add(c2s_self_presence, Host, ?MODULE, c2s_self_presence, 50),
true ->
ok
end,
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_FLEX_OFFLINE,
?MODULE, handle_offline_query, IQDisc);
init([Host, Opts]) ->
process_flag(trap_exit, true),
State = init_state(Host, Opts),
- IQDisc = gen_mod:get_opt(iqdisc, Opts, no_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
register_iq_handlers(Host, IQDisc),
case State#state.send_pings of
true -> register_hooks(Host);
handle_cast({reload, Host, NewOpts, OldOpts},
#state{timers = Timers} = OldState) ->
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} -> register_iq_handlers(Host, IQDisc);
true -> ok
end,
-callback remove_user(binary(), binary()) -> any().
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
Mod:init(Host, Opts),
ejabberd_hooks:add(disco_local_features, Host, ?MODULE,
true ->
ok
end,
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PRIVACY,
?MODULE, process_iq, IQDisc);
-callback remove_user(binary(), binary()) -> any().
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
Mod:init(Host, Opts),
ejabberd_hooks:add(remove_user, Host, ?MODULE,
true ->
ok
end,
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PRIVATE,
?MODULE, process_sm_iq, IQDisc);
init([Host, Opts]) ->
process_flag(trap_exit, true),
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
MyHost = gen_mod:get_opt_host(Host, Opts, <<"proxy.@HOST@">>),
gen_iq_handler:add_iq_handler(ejabberd_local, MyHost, ?NS_DISCO_INFO,
?MODULE, process_disco_info, IQDisc),
handle_cast({reload, ServerHost, NewOpts, OldOpts}, State) ->
NewHost = gen_mod:get_opt_host(ServerHost, NewOpts, <<"proxy.@HOST@">>),
OldHost = gen_mod:get_opt_host(ServerHost, OldOpts, <<"proxy.@HOST@">>),
- NewIQDisc = gen_mod:get_opt(iqdisc, NewOpts, one_queue),
- OldIQDisc = gen_mod:get_opt(iqdisc, OldOpts, one_queue),
+ NewIQDisc = gen_mod:get_opt(iqdisc, NewOpts, gen_iq_handler:iqdisc(ServerHost)),
+ OldIQDisc = gen_mod:get_opt(iqdisc, OldOpts, gen_iq_handler:iqdisc(ServerHost)),
if (NewIQDisc /= OldIQDisc) or (NewHost /= OldHost) ->
gen_iq_handler:add_iq_handler(ejabberd_local, NewHost, ?NS_DISCO_INFO,
?MODULE, process_disco_info, NewIQDisc),
ejabberd_router:register_route(Host, ServerHost),
Access = gen_mod:get_opt(access_createnode, Opts, all),
PepOffline = gen_mod:get_opt(ignore_pep_from_offline, Opts, true),
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
LastItemCache = gen_mod:get_opt(last_item_cache, Opts, false),
MaxItemsNode = gen_mod:get_opt(max_items_node, Opts, ?MAXITEMS),
MaxSubsNode = gen_mod:get_opt(max_subscriptions_node, Opts),
-include("xmpp.hrl").
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
?NS_REGISTER, ?MODULE, process_iq, IQDisc),
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
?NS_REGISTER).
reload(Host, NewOpts, OldOpts) ->
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_REGISTER,
?MODULE, process_iq, IQDisc),
{subscription(), [binary()]}.
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
Mod = gen_mod:db_mod(Host, Opts, ?MODULE),
Mod:init(Host, Opts),
ejabberd_hooks:add(roster_get, Host, ?MODULE,
true ->
ok
end,
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_ROSTER,
?MODULE, process_iq, IQDisc);
-include("xmpp.hrl").
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_SIC_0,
?MODULE, process_local_iq, IQDisc),
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_SIC_0,
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_SIC_1).
reload(Host, NewOpts, OldOpts) ->
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_SIC_0,
?MODULE, process_local_iq, IQDisc),
-include("xmpp.hrl").
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_STATS,
?MODULE, process_iq, IQDisc).
-include("xmpp.hrl").
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
?NS_TIME, ?MODULE, process_local_iq, IQDisc).
?NS_TIME).
reload(Host, NewOpts, OldOpts) ->
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_TIME,
?MODULE, process_local_iq, IQDisc);
Mod:init(Host, Opts),
ejabberd_hooks:add(remove_user, Host, ?MODULE,
remove_user, 50),
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
?NS_VCARD, ?MODULE, process_local_iq, IQDisc),
gen_iq_handler:add_iq_handler(ejabberd_sm, Host,
-include("xmpp.hrl").
start(Host, Opts) ->
- IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
+ IQDisc = gen_mod:get_opt(iqdisc, Opts, gen_iq_handler:iqdisc(Host)),
gen_iq_handler:add_iq_handler(ejabberd_local, Host,
?NS_VERSION, ?MODULE, process_local_iq,
IQDisc).
?NS_VERSION).
reload(Host, NewOpts, OldOpts) ->
- case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, one_queue) of
+ case gen_mod:is_equal_opt(iqdisc, NewOpts, OldOpts, gen_iq_handler:iqdisc(Host)) of
{false, IQDisc, _} ->
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VERSION,
?MODULE, process_local_iq, IQDisc);