25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

mod_pubsub: initial update to new hooks API (using binaries). mod_pubsub is still unusable with exmpp.

SVN Revision: 1809
This commit is contained in:
Pablo Polvorin 2009-01-12 18:17:05 +00:00
parent 49210e3099
commit e8f630b93a
2 changed files with 28 additions and 25 deletions

View File

@ -1,6 +1,8 @@
2009-01-11 Pablo Polvorin <pablo.polvorin@process-one.net>
* src/mod_pubsub/mod_pubsub.erl: Fix typo.
* src/mod_pubsub/mod_pubsub.erl: Fix typo, initial update
to new hooks API (using binaries). mod_pubsub is still
unusable with exmpp.
* src/mod_caps.erl, src/ejabberd_c2s.erl: Apply commit
1212 (caps handling fix), was incorrectly overwritten on

View File

@ -156,21 +156,21 @@ init([ServerHost, Opts]) ->
?DEBUG("pubsub init ~p ~p",[ServerHost,Opts]),
Host = gen_mod:get_opt_host(ServerHost, Opts, "pubsub.@HOST@"),
Access = gen_mod:get_opt(access_createnode, Opts, all),
ServerHostB = list_to_binary(ServerHost),
mod_disco:register_feature(ServerHost, ?NS_PUBSUB_s),
ejabberd_hooks:add(disco_local_identity, ServerHost, ?MODULE, disco_local_identity, 75),
ejabberd_hooks:add(disco_local_features, ServerHost, ?MODULE, disco_local_features, 75),
ejabberd_hooks:add(disco_local_items, ServerHost, ?MODULE, disco_local_items, 75),
ejabberd_hooks:add(disco_sm_identity, ServerHost, ?MODULE, disco_sm_identity, 75),
ejabberd_hooks:add(disco_sm_features, ServerHost, ?MODULE, disco_sm_features, 75),
ejabberd_hooks:add(disco_sm_items, ServerHost, ?MODULE, disco_sm_items, 75),
ejabberd_hooks:add(presence_probe_hook, ServerHost, ?MODULE, presence_probe, 50),
ejabberd_hooks:add(remove_user, ServerHost, ?MODULE, remove_user, 50),
ejabberd_hooks:add(disco_local_identity, ServerHostB, ?MODULE, disco_local_identity, 75),
ejabberd_hooks:add(disco_local_features, ServerHostB, ?MODULE, disco_local_features, 75),
ejabberd_hooks:add(disco_local_items, ServerHostB, ?MODULE, disco_local_items, 75),
ejabberd_hooks:add(disco_sm_identity, ServerHostB, ?MODULE, disco_sm_identity, 75),
ejabberd_hooks:add(disco_sm_features, ServerHostB, ?MODULE, disco_sm_features, 75),
ejabberd_hooks:add(disco_sm_items, ServerHostB, ?MODULE, disco_sm_items, 75),
ejabberd_hooks:add(presence_probe_hook, ServerHostB, ?MODULE, presence_probe, 50),
ejabberd_hooks:add(remove_user, ServerHostB, ?MODULE, remove_user, 50),
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
ServerB = list_to_binary(ServerHost),
lists:foreach(
fun({NS,Mod,Fun}) ->
gen_iq_handler:add_iq_handler(
Mod, ServerB, NS, ?MODULE, Fun, IQDisc)
Mod, ServerHostB, NS, ?MODULE, Fun, IQDisc)
end,
[{?NS_PUBSUB, ejabberd_local, iq_local},
{?NS_PUBSUB_OWNER, ejabberd_local, iq_local},
@ -411,8 +411,8 @@ disco_sm_items(Acc, From, To, NodeB, _Lang) ->
%% presence hooks handling functions
%%
presence_probe(#jid{ldomain = Host} = JID, JID, Pid) ->
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
presence_probe(JID, JID, Pid) ->
Proc = gen_mod:get_module_proc(exmpp_jid:ldomain_as_list(JID), ?PROCNAME),
gen_server:cast(Proc, {presence, JID, Pid});
presence_probe(_, _, _) ->
ok.
@ -577,17 +577,17 @@ terminate(_Reason, #state{host = Host,
plugins = Plugins}) ->
terminate_plugins(Host, ServerHost, Plugins, TreePlugin),
ejabberd_router:unregister_route(Host),
ejabberd_hooks:delete(disco_local_identity, ServerHost, ?MODULE, disco_local_identity, 75),
ejabberd_hooks:delete(disco_local_features, ServerHost, ?MODULE, disco_local_features, 75),
ejabberd_hooks:delete(disco_local_items, ServerHost, ?MODULE, disco_local_items, 75),
ejabberd_hooks:delete(disco_sm_identity, ServerHost, ?MODULE, disco_sm_identity, 75),
ejabberd_hooks:delete(disco_sm_features, ServerHost, ?MODULE, disco_sm_features, 75),
ejabberd_hooks:delete(disco_sm_items, ServerHost, ?MODULE, disco_sm_items, 75),
ejabberd_hooks:delete(presence_probe_hook, ServerHost, ?MODULE, presence_probe, 50),
ejabberd_hooks:delete(remove_user, ServerHost, ?MODULE, remove_user, 50),
ServerB = list_to_binary(ServerHost),
ServerHostB = list_to_binary(ServerHost),
ejabberd_hooks:delete(disco_local_identity, ServerHostB, ?MODULE, disco_local_identity, 75),
ejabberd_hooks:delete(disco_local_features, ServerHostB, ?MODULE, disco_local_features, 75),
ejabberd_hooks:delete(disco_local_items, ServerHostB, ?MODULE, disco_local_items, 75),
ejabberd_hooks:delete(disco_sm_identity, ServerHostB, ?MODULE, disco_sm_identity, 75),
ejabberd_hooks:delete(disco_sm_features, ServerHostB, ?MODULE, disco_sm_features, 75),
ejabberd_hooks:delete(disco_sm_items, ServerHostB, ?MODULE, disco_sm_items, 75),
ejabberd_hooks:delete(presence_probe_hook, ServerHostB, ?MODULE, presence_probe, 50),
ejabberd_hooks:delete(remove_user, ServerHostB, ?MODULE, remove_user, 50),
lists:foreach(fun({NS,Mod}) ->
gen_iq_handler:remove_iq_handler(Mod, ServerB, NS)
gen_iq_handler:remove_iq_handler(Mod, ServerHostB, NS)
end, [{?NS_PUBSUB, ejabberd_local},
{?NS_PUBSUB_OWNER, ejabberd_local},
{?NS_PUBSUB, ejabberd_sm},
@ -2660,8 +2660,9 @@ set_xoption([_ | Opts], NewOpts) ->
%%%% plugin handling
plugins(Host) ->
case ets:lookup(gen_mod:get_module_proc(Host, pubsub_state), plugins) of
plugins(Host) when is_binary(Host) ->
HostL = binary_to_list(Host),
case ets:lookup(gen_mod:get_module_proc(HostL, pubsub_state), plugins) of
[{plugins, PL}] -> PL;
_ -> [?STDNODE]
end.