mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Update gen_iq_handler API, require the 'Host' argument to be in binary() format.
Fix bug in vcard user search, odbc backend. SVN Revision: 1796
This commit is contained in:
parent
36080fb682
commit
c77f7e727b
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
2009-01-10 Pablo Polvorin <pablo.polvorin@process-one.net>
|
||||
|
||||
* src/mod_vcard_odbc.erl: Fix bug in user search.
|
||||
|
||||
* src/mod_vcard_ldap.erl, src/mod_vcard.erl, src/mod_configure.erl,
|
||||
src/ejabberd_sm.erl, src/mod_privacy_odbc.erl, src/ejabberd_c2s.erl,
|
||||
src/ejabberd_local.erl, src/mod_privacy.erl, src/mod_adhoc.erl,
|
||||
src/mod_pubsub/mod_pubsub.erl, src/mod_vcard_odbc.erl, src/mod_stats.erl,
|
||||
src/mod_last.erl, src/mod_private.erl, src/mod_roster.erl,
|
||||
src/mod_disco.erl, src/mod_private_odbc.erl, src/mod_configure2.erl,
|
||||
src/mod_roster_odbc.erl, src/mod_register.erl, src/mod_version.erl,
|
||||
src/mod_caps.erl, src/mod_last_odbc.erl, src/mod_time.erl: Update
|
||||
gen_iq_handler API, require the 'Host' argument to be in binary() format.
|
||||
|
||||
2009-01-10 Christophe Romain <christophe.romain@process-one.net>
|
||||
|
||||
* src/mod_pubsub/node_default.erl: fix unsubscription of full jid
|
||||
|
@ -1162,7 +1162,7 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
|
||||
true ->
|
||||
case exmpp_iq:get_request(Packet) of
|
||||
#xmlel{ns = ?NS_VCARD} ->
|
||||
Host = binary_to_list(StateData#state.server),
|
||||
Host = StateData#state.server,
|
||||
case ets:lookup(sm_iqtable, {?NS_VCARD, Host}) of
|
||||
[{_, Module, Function, Opts}] ->
|
||||
gen_iq_handler:handle(Host, Module, Function, Opts,
|
||||
|
@ -76,7 +76,7 @@ start_link() ->
|
||||
process_iq(From, To, Packet) ->
|
||||
case exmpp_iq:xmlel_to_iq(Packet) of
|
||||
#iq{kind = request, ns = XMLNS} = IQ_Rec ->
|
||||
Host = exmpp_jid:ldomain_as_list(To),
|
||||
Host = exmpp_jid:ldomain(To),
|
||||
case ets:lookup(?IQTABLE, {XMLNS, Host}) of
|
||||
[{_, Module, Function}] ->
|
||||
ResIQ = Module:Function(From, To, IQ_Rec),
|
||||
|
@ -661,7 +661,7 @@ get_max_user_sessions(JID) ->
|
||||
process_iq(From, To, Packet) ->
|
||||
case exmpp_iq:xmlel_to_iq(Packet) of
|
||||
#iq{kind = request, ns = XMLNS} = IQ_Rec ->
|
||||
LServer = exmpp_jid:ldomain_as_list(To),
|
||||
LServer = exmpp_jid:ldomain(To),
|
||||
case ets:lookup(sm_iqtable, {XMLNS, LServer}) of
|
||||
[{_, Module, Function}] ->
|
||||
ResIQ = Module:Function(From, To, IQ_Rec),
|
||||
|
@ -51,9 +51,9 @@ start(Host, Opts) ->
|
||||
HostB = list_to_binary(Host),
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_ADHOC,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, HostB, ?NS_ADHOC,
|
||||
?MODULE, process_local_iq, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_ADHOC,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_ADHOC,
|
||||
?MODULE, process_sm_iq, IQDisc),
|
||||
|
||||
ejabberd_hooks:add(disco_local_identity, HostB, ?MODULE, get_local_identity, 99),
|
||||
@ -76,8 +76,8 @@ stop(Host) ->
|
||||
ejabberd_hooks:delete(disco_local_features, HostB, ?MODULE, get_local_features, 99),
|
||||
ejabberd_hooks:delete(disco_local_identity, HostB, ?MODULE, get_local_identity, 99),
|
||||
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_ADHOC),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_ADHOC).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_ADHOC),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, HostB, ?NS_ADHOC).
|
||||
|
||||
%-------------------------------------------------------------------------
|
||||
|
||||
|
@ -262,7 +262,7 @@ handle_cast({note_caps, From,
|
||||
'node', lists:concat([Node, "#", SubNode])),
|
||||
Stanza = exmpp_iq:get(?NS_JABBER_CLIENT, Query, ID),
|
||||
ejabberd_local:register_iq_response_handler
|
||||
(Host, ID, ?MODULE, handle_disco_response),
|
||||
(list_to_binary(Host), ID, ?MODULE, handle_disco_response),
|
||||
ejabberd_router:route(exmpp_jid:make_bare_jid(Host),
|
||||
From, Stanza),
|
||||
timer:send_after(?CAPS_QUERY_TIMEOUT, self(), {disco_timeout, ID}),
|
||||
@ -322,7 +322,7 @@ handle_cast({disco_timeout, ID}, #state{host = Host, disco_requests = Requests}
|
||||
%% do not wait a response anymore for this IQ, client certainly will never answer
|
||||
NewRequests = case ?DICT:is_key(ID, Requests) of
|
||||
true ->
|
||||
ejabberd_local:unregister_iq_response_handler(Host, ID),
|
||||
ejabberd_local:unregister_iq_response_handler(list_to_binary(Host), ID),
|
||||
?DICT:erase(ID, Requests);
|
||||
false ->
|
||||
Requests
|
||||
|
@ -84,8 +84,8 @@ stop(Host) ->
|
||||
ejabberd_hooks:delete(disco_local_identity, HostB, ?MODULE, get_local_identity, 50),
|
||||
ejabberd_hooks:delete(disco_local_features, HostB, ?MODULE, get_local_features, 50),
|
||||
ejabberd_hooks:delete(disco_local_items, HostB, ?MODULE, get_local_items, 50),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_ADHOC),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_ADHOC).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, HostB, ?NS_ADHOC),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_ADHOC).
|
||||
|
||||
%%%-----------------------------------------------------------------------
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
start(Host, Opts) ->
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_ECONFIGURE,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, list_to_binary(Host), ?NS_ECONFIGURE,
|
||||
?MODULE, process_local_iq, IQDisc),
|
||||
% Add nss/names/attrs used by this module to the known lists of Exmpp.
|
||||
exmpp_xml:add_autoload_known_nss([?NS_ECONFIGURE]),
|
||||
@ -67,7 +67,7 @@ start(Host, Opts) ->
|
||||
ok.
|
||||
|
||||
stop(Host) ->
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_ECONFIGURE).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, list_to_binary(Host), ?NS_ECONFIGURE).
|
||||
|
||||
|
||||
process_local_iq(From, To, #iq{type = Type, payload = Request} = IQ_Rec) ->
|
||||
|
@ -64,13 +64,13 @@ start(Host, Opts) ->
|
||||
ejabberd_local:refresh_iq_handlers(),
|
||||
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_ITEMS,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, HostB, ?NS_DISCO_ITEMS,
|
||||
?MODULE, process_local_iq_items, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, HostB, ?NS_DISCO_INFO,
|
||||
?MODULE, process_local_iq_info, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_DISCO_ITEMS,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_DISCO_ITEMS,
|
||||
?MODULE, process_sm_iq_items, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_DISCO_INFO,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_DISCO_INFO,
|
||||
?MODULE, process_sm_iq_info, IQDisc),
|
||||
|
||||
catch ets:new(disco_features, [named_table, ordered_set, public]),
|
||||
@ -103,10 +103,10 @@ stop(Host) ->
|
||||
ejabberd_hooks:delete(disco_local_identity, HostB, ?MODULE, get_local_identity, 100),
|
||||
ejabberd_hooks:delete(disco_local_features, HostB, ?MODULE, get_local_features, 100),
|
||||
ejabberd_hooks:delete(disco_local_items, HostB, ?MODULE, get_local_services, 100),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_DISCO_ITEMS),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_DISCO_INFO),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_DISCO_ITEMS),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_DISCO_INFO),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, HostB, ?NS_DISCO_ITEMS),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, HostB, ?NS_DISCO_INFO),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_DISCO_ITEMS),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_DISCO_INFO),
|
||||
catch ets:match_delete(disco_features, {{'_', Host}}),
|
||||
catch ets:match_delete(disco_extra_domains, {{'_', Host}}),
|
||||
ok.
|
||||
|
@ -53,9 +53,9 @@ start(Host, Opts) ->
|
||||
[{disc_copies, [node()]},
|
||||
{attributes, record_info(fields, last_activity)}]),
|
||||
update_table(),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_LAST_ACTIVITY,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, HostB, ?NS_LAST_ACTIVITY,
|
||||
?MODULE, process_local_iq, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_LAST_ACTIVITY,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_LAST_ACTIVITY,
|
||||
?MODULE, process_sm_iq, IQDisc),
|
||||
ejabberd_hooks:add(remove_user, HostB,
|
||||
?MODULE, remove_user, 50),
|
||||
@ -68,8 +68,8 @@ stop(Host) ->
|
||||
?MODULE, remove_user, 50),
|
||||
ejabberd_hooks:delete(unset_presence_hook, HostB,
|
||||
?MODULE, on_presence_update, 50),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_LAST_ACTIVITY),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_LAST_ACTIVITY).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, HostB, ?NS_LAST_ACTIVITY),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_LAST_ACTIVITY).
|
||||
|
||||
process_local_iq(_From, _To, #iq{type = get} = IQ_Rec) ->
|
||||
Sec = trunc(element(1, erlang:statistics(wall_clock))/1000),
|
||||
|
@ -46,9 +46,9 @@
|
||||
start(Host, Opts) ->
|
||||
HostB = list_to_binary(Host),
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_LAST_ACTIVITY,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, HostB, ?NS_LAST_ACTIVITY,
|
||||
?MODULE, process_local_iq, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_LAST_ACTIVITY,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_LAST_ACTIVITY,
|
||||
?MODULE, process_sm_iq, IQDisc),
|
||||
ejabberd_hooks:add(remove_user, HostB,
|
||||
?MODULE, remove_user, 50),
|
||||
@ -61,8 +61,8 @@ stop(Host) ->
|
||||
?MODULE, remove_user, 50),
|
||||
ejabberd_hooks:delete(unset_presence_hook, HostB,
|
||||
?MODULE, on_presence_update, 50),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_LAST_ACTIVITY),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_LAST_ACTIVITY).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, HostB, ?NS_LAST_ACTIVITY),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_LAST_ACTIVITY).
|
||||
|
||||
process_local_iq(_From, _To, #iq{type = get} = IQ_Rec) ->
|
||||
Sec = trunc(element(1, erlang:statistics(wall_clock))/1000),
|
||||
|
@ -59,7 +59,7 @@ start(Host, Opts) ->
|
||||
?MODULE, check_packet, 50),
|
||||
ejabberd_hooks:add(privacy_updated_list, HostB,
|
||||
?MODULE, updated_list, 50),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PRIVACY,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_PRIVACY,
|
||||
?MODULE, process_iq, IQDisc).
|
||||
|
||||
stop(Host) ->
|
||||
@ -74,7 +74,7 @@ stop(Host) ->
|
||||
?MODULE, check_packet, 50),
|
||||
ejabberd_hooks:delete(privacy_updated_list, HostB,
|
||||
?MODULE, updated_list, 50),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_PRIVACY).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_PRIVACY).
|
||||
|
||||
process_iq(_From, _To, IQ_Rec) ->
|
||||
exmpp_iq:error(IQ_Rec, 'not-allowed').
|
||||
|
@ -55,7 +55,7 @@ start(Host, Opts) ->
|
||||
?MODULE, check_packet, 50),
|
||||
ejabberd_hooks:add(privacy_updated_list, HostB,
|
||||
?MODULE, updated_list, 50),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PRIVACY,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_PRIVACY,
|
||||
?MODULE, process_iq, IQDisc).
|
||||
|
||||
stop(Host) ->
|
||||
@ -70,7 +70,7 @@ stop(Host) ->
|
||||
?MODULE, check_packet, 50),
|
||||
ejabberd_hooks:delete(privacy_updated_list, HostB,
|
||||
?MODULE, updated_list, 50),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_PRIVACY).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_PRIVACY).
|
||||
|
||||
process_iq(_From, _To, IQ_Rec) ->
|
||||
exmpp_iq:error(IQ_Rec, 'not-allowed').
|
||||
|
@ -49,14 +49,14 @@ start(Host, Opts) ->
|
||||
update_table(),
|
||||
ejabberd_hooks:add(remove_user, HostB,
|
||||
?MODULE, remove_user, 50),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PRIVATE,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_PRIVATE,
|
||||
?MODULE, process_sm_iq, IQDisc).
|
||||
|
||||
stop(Host) ->
|
||||
HostB = list_to_binary(Host),
|
||||
ejabberd_hooks:delete(remove_user, HostB,
|
||||
?MODULE, remove_user, 50),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_PRIVATE).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_PRIVATE).
|
||||
|
||||
|
||||
process_sm_iq(From, To, #iq{type = Type} = IQ_Rec) ->
|
||||
|
@ -43,14 +43,14 @@ start(Host, Opts) ->
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
ejabberd_hooks:add(remove_user, HostB,
|
||||
?MODULE, remove_user, 50),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_PRIVATE,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_PRIVATE,
|
||||
?MODULE, process_sm_iq, IQDisc).
|
||||
|
||||
stop(Host) ->
|
||||
HostB = list_to_binary(Host),
|
||||
ejabberd_hooks:delete(remove_user, HostB,
|
||||
?MODULE, remove_user, 50),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_PRIVATE).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_PRIVATE).
|
||||
|
||||
|
||||
process_sm_iq(From, To, #iq{type = Type} = IQ_Rec) ->
|
||||
|
@ -166,10 +166,11 @@ init([ServerHost, Opts]) ->
|
||||
ejabberd_hooks:add(presence_probe_hook, ServerHost, ?MODULE, presence_probe, 50),
|
||||
ejabberd_hooks:add(remove_user, ServerHost, ?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, ServerHost, NS, ?MODULE, Fun, IQDisc)
|
||||
Mod, ServerB, NS, ?MODULE, Fun, IQDisc)
|
||||
end,
|
||||
[{?NS_PUBSUB, ejabberd_local, iq_local},
|
||||
{?NS_PUBSUB_OWNER, ejabberd_local, iq_local},
|
||||
@ -584,8 +585,9 @@ terminate(_Reason, #state{host = Host,
|
||||
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),
|
||||
lists:foreach(fun({NS,Mod}) ->
|
||||
gen_iq_handler:remove_iq_handler(Mod, ServerHost, NS)
|
||||
gen_iq_handler:remove_iq_handler(Mod, ServerB, NS)
|
||||
end, [{?NS_PUBSUB, ejabberd_local},
|
||||
{?NS_PUBSUB_OWNER, ejabberd_local},
|
||||
{?NS_PUBSUB, ejabberd_sm},
|
||||
|
@ -42,9 +42,9 @@
|
||||
start(Host, Opts) ->
|
||||
HostB = list_to_binary(Host),
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_INBAND_REGISTER,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, HostB, ?NS_INBAND_REGISTER,
|
||||
?MODULE, process_iq, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_INBAND_REGISTER,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_INBAND_REGISTER,
|
||||
?MODULE, process_iq, IQDisc),
|
||||
ejabberd_hooks:add(c2s_stream_features, HostB,
|
||||
?MODULE, stream_feature_register, 50),
|
||||
@ -63,8 +63,8 @@ stop(Host) ->
|
||||
?MODULE, stream_feature_register, 50),
|
||||
ejabberd_hooks:delete(c2s_unauthenticated_iq, HostB,
|
||||
?MODULE, unauthenticated_iq_register, 50),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_INBAND_REGISTER),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_INBAND_REGISTER).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, HostB, ?NS_INBAND_REGISTER),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_INBAND_REGISTER).
|
||||
|
||||
|
||||
stream_feature_register(Acc) ->
|
||||
|
@ -79,7 +79,7 @@ start(Host, Opts) ->
|
||||
?MODULE, webadmin_page, 50),
|
||||
ejabberd_hooks:add(webadmin_user, HostB,
|
||||
?MODULE, webadmin_user, 50),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_ROSTER,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_ROSTER,
|
||||
?MODULE, process_iq, IQDisc).
|
||||
|
||||
stop(Host) ->
|
||||
@ -104,7 +104,7 @@ stop(Host) ->
|
||||
?MODULE, webadmin_page, 50),
|
||||
ejabberd_hooks:delete(webadmin_user, HostB,
|
||||
?MODULE, webadmin_user, 50),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB,
|
||||
?NS_ROSTER).
|
||||
|
||||
|
||||
|
@ -74,7 +74,7 @@ start(Host, Opts) ->
|
||||
?MODULE, webadmin_page, 50),
|
||||
ejabberd_hooks:add(webadmin_user, HostB,
|
||||
?MODULE, webadmin_user, 50),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_ROSTER,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_ROSTER,
|
||||
?MODULE, process_iq, IQDisc).
|
||||
|
||||
stop(Host) ->
|
||||
@ -99,7 +99,7 @@ stop(Host) ->
|
||||
?MODULE, webadmin_page, 50),
|
||||
ejabberd_hooks:delete(webadmin_user, HostB,
|
||||
?MODULE, webadmin_user, 50),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_ROSTER).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_ROSTER).
|
||||
|
||||
|
||||
process_iq(From, To, IQ_Rec) ->
|
||||
|
@ -37,11 +37,11 @@
|
||||
|
||||
start(Host, Opts) ->
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_STATS,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, list_to_binary(Host), ?NS_STATS,
|
||||
?MODULE, process_local_iq, IQDisc).
|
||||
|
||||
stop(Host) ->
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_STATS).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, list_to_binary(Host), ?NS_STATS).
|
||||
|
||||
|
||||
process_local_iq(_From, To, #iq{type = get,
|
||||
|
@ -40,11 +40,11 @@
|
||||
|
||||
start(Host, Opts) ->
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_TIME,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, list_to_binary(Host), ?NS_TIME,
|
||||
?MODULE, process_local_iq, IQDisc).
|
||||
|
||||
stop(Host) ->
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_TIME).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, list_to_binary(Host), ?NS_TIME).
|
||||
|
||||
process_local_iq(_From, _To, #iq{type = get} = IQ_Rec) ->
|
||||
UTC = jlib:timestamp_to_iso(calendar:universal_time()),
|
||||
|
@ -85,9 +85,9 @@ start(Host, Opts) ->
|
||||
ejabberd_hooks:add(remove_user, HostB,
|
||||
?MODULE, remove_user, 50),
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, HostB, ?NS_VCARD,
|
||||
?MODULE, process_local_iq, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_VCARD,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_VCARD,
|
||||
?MODULE, process_sm_iq, IQDisc),
|
||||
ejabberd_hooks:add(disco_sm_features, HostB, ?MODULE, get_sm_features, 50),
|
||||
MyHost = gen_mod:get_opt_host(Host, Opts, "vjud.@HOST@"),
|
||||
@ -126,9 +126,9 @@ stop(Host) ->
|
||||
HostB = list_to_binary(Host),
|
||||
ejabberd_hooks:delete(remove_user, HostB,
|
||||
?MODULE, remove_user, 50),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host,
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, HostB,
|
||||
?NS_VCARD),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host,
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB,
|
||||
?NS_VCARD),
|
||||
ejabberd_hooks:delete(disco_sm_features, HostB, ?MODULE, get_sm_features, 50),
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
|
@ -153,9 +153,10 @@ stop(Host) ->
|
||||
|
||||
terminate(_Reason, State) ->
|
||||
Host = State#state.serverhost,
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_VCARD),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_VCARD),
|
||||
ejabberd_hooks:delete(disco_sm_features, list_to_binary(Host), ?MODULE, get_sm_features, 50),
|
||||
HostB = list_to_binary(Host),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, HostB, ?NS_VCARD),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_VCARD),
|
||||
ejabberd_hooks:delete(disco_sm_features, HostB, ?MODULE, get_sm_features, 50),
|
||||
case State#state.search of
|
||||
true ->
|
||||
ejabberd_router:unregister_route(State#state.myhost);
|
||||
@ -168,11 +169,12 @@ start_link(Host, Opts) ->
|
||||
gen_server:start_link({local, Proc}, ?MODULE, [Host, Opts], []).
|
||||
|
||||
init([Host, Opts]) ->
|
||||
HostB = list_to_binary(Host),
|
||||
State = parse_options(Host, Opts),
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, parallel),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, HostB, ?NS_VCARD,
|
||||
?MODULE, process_local_iq, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_VCARD,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_VCARD,
|
||||
?MODULE, process_sm_iq, IQDisc),
|
||||
ejabberd_hooks:add(disco_sm_features,
|
||||
list_to_binary(Host), ?MODULE, get_sm_features, 50),
|
||||
|
@ -49,9 +49,9 @@ start(Host, Opts) ->
|
||||
ejabberd_hooks:add(remove_user, HostB,
|
||||
?MODULE, remove_user, 50),
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_VCARD,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, HostB, ?NS_VCARD,
|
||||
?MODULE, process_local_iq, IQDisc),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, Host, ?NS_VCARD,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_sm, HostB, ?NS_VCARD,
|
||||
?MODULE, process_sm_iq, IQDisc),
|
||||
ejabberd_hooks:add(disco_sm_features, HostB, ?MODULE, get_sm_features, 50),
|
||||
MyHost = gen_mod:get_opt_host(Host, Opts, "vjud.@HOST@"),
|
||||
@ -90,8 +90,8 @@ stop(Host) ->
|
||||
HostB = list_to_binary(Host),
|
||||
ejabberd_hooks:delete(remove_user, HostB,
|
||||
?MODULE, remove_user, 50),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_VCARD),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, Host, ?NS_VCARD),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, HostB, ?NS_VCARD),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, HostB, ?NS_VCARD),
|
||||
ejabberd_hooks:delete(disco_sm_features, HostB, ?MODULE, get_sm_features, 50),
|
||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||
Proc ! stop,
|
||||
@ -295,35 +295,31 @@ do_route(ServerHost, From, To, Packet) ->
|
||||
Lang = exmpp_stanza:get_lang(Packet),
|
||||
case {Type, Request#xmlel.ns} of
|
||||
{set, ?NS_SEARCH} ->
|
||||
XDataEl = find_xdata_el(Request),
|
||||
case XDataEl of
|
||||
false ->
|
||||
Err = exmpp_iq:error(Packet, 'bad-request'),
|
||||
ejabberd_router:route(To, From, Err);
|
||||
_ ->
|
||||
XData = jlib:parse_xdata_submit(XDataEl),
|
||||
case XData of
|
||||
invalid ->
|
||||
Err = exmpp_iq:error(Packet,
|
||||
'bad-request'),
|
||||
ejabberd_router:route(To, From,
|
||||
Err);
|
||||
_ ->
|
||||
Result = #xmlel{
|
||||
ns = ?NS_SEARCH,
|
||||
name = 'query',
|
||||
children = [
|
||||
#xmlel{
|
||||
ns = ?NS_DATA_FORMS,
|
||||
name = 'x',
|
||||
attrs = [#xmlattr{name = 'type',
|
||||
value = <<"result">>}],
|
||||
children = search_result(Lang,
|
||||
To, ServerHost, XData)}]},
|
||||
ResIQ = exmpp_iq:result(Packet,
|
||||
Result),
|
||||
ejabberd_router:route(
|
||||
To, From, exmpp_iq:iq_to_xmlel(ResIQ))
|
||||
XDataEl = find_xdata_el(Request),
|
||||
case XDataEl of
|
||||
false ->
|
||||
Err = exmpp_iq:error(Packet, 'bad-request'),
|
||||
ejabberd_router:route(To, From, Err);
|
||||
_ ->
|
||||
XData = jlib:parse_xdata_submit(XDataEl),
|
||||
case XData of
|
||||
invalid ->
|
||||
Err = exmpp_iq:error(Packet, 'bad-request'),
|
||||
ejabberd_router:route(To, From, Err);
|
||||
_ ->
|
||||
Result = #xmlel{ns = ?NS_SEARCH,
|
||||
name = 'query',
|
||||
children = [
|
||||
#xmlel{ns = ?NS_DATA_FORMS,
|
||||
name = 'x',
|
||||
attrs = [
|
||||
#xmlattr{name = 'type',
|
||||
value = <<"result">>}],
|
||||
children = search_result(Lang,
|
||||
To, ServerHost, XData)}]},
|
||||
ResIQ = exmpp_iq:result(Packet, Result),
|
||||
ejabberd_router:route(
|
||||
To, From, ResIQ)
|
||||
end
|
||||
end;
|
||||
{get, ?NS_SEARCH} ->
|
||||
|
@ -41,11 +41,11 @@
|
||||
|
||||
start(Host, Opts) ->
|
||||
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_SOFT_VERSION,
|
||||
gen_iq_handler:add_iq_handler(ejabberd_local, list_to_binary(Host), ?NS_SOFT_VERSION,
|
||||
?MODULE, process_local_iq, IQDisc).
|
||||
|
||||
stop(Host) ->
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_SOFT_VERSION).
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_local, list_to_binary(Host), ?NS_SOFT_VERSION).
|
||||
|
||||
|
||||
process_local_iq(_From, To, #iq{type = Type} = IQ_Rec) ->
|
||||
|
Loading…
Reference in New Issue
Block a user