mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Merge branch 'master' of git+ssh://gitorious.process-one.net/ejabberd/mainline
This commit is contained in:
commit
75a85beb80
@ -11,6 +11,7 @@
|
|||||||
* The only supported migrations are
|
* The only supported migrations are
|
||||||
* from any ejabberd 0.9.0 ... 2.1.5 to the final 3.0.0.
|
* from any ejabberd 0.9.0 ... 2.1.5 to the final 3.0.0.
|
||||||
* Don't use this preliminary ejabberd release for a production server.
|
* Don't use this preliminary ejabberd release for a production server.
|
||||||
|
* Also, Pubsub/PEP is not yet ready for alpha-testing in this release.
|
||||||
* You can test this release with a blank database or with a copy of your
|
* You can test this release with a blank database or with a copy of your
|
||||||
* production database, but don't let your users connect to this copy
|
* production database, but don't let your users connect to this copy
|
||||||
* because their changes may get lost when you upgrade to the final 3.0.0.
|
* because their changes may get lost when you upgrade to the final 3.0.0.
|
||||||
|
@ -34,10 +34,12 @@
|
|||||||
|
|
||||||
-export([route/3,
|
-export([route/3,
|
||||||
route_iq/4,
|
route_iq/4,
|
||||||
|
route_iq/5,
|
||||||
process_iq_reply/3,
|
process_iq_reply/3,
|
||||||
register_iq_handler/4,
|
register_iq_handler/4,
|
||||||
register_iq_handler/5,
|
register_iq_handler/5,
|
||||||
register_iq_response_handler/4,
|
register_iq_response_handler/4,
|
||||||
|
register_iq_response_handler/5,
|
||||||
unregister_iq_handler/2,
|
unregister_iq_handler/2,
|
||||||
unregister_iq_response_handler/2,
|
unregister_iq_response_handler/2,
|
||||||
refresh_iq_handlers/0,
|
refresh_iq_handlers/0,
|
||||||
@ -146,19 +148,31 @@ route(From, To, Packet) ->
|
|||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
route_iq(From, To, #iq{type = Type} = IQ, F) when is_function(F) ->
|
route_iq(From, To, IQ, F) ->
|
||||||
|
route_iq(From, To, IQ, F, undefined).
|
||||||
|
|
||||||
|
route_iq(From, To, #iq{type = Type} = IQ, F, Timeout) when is_function(F) ->
|
||||||
Packet = if Type == set; Type == get ->
|
Packet = if Type == set; Type == get ->
|
||||||
ID = list_to_binary(ejabberd_router:make_id()),
|
ID = list_to_binary(ejabberd_router:make_id()),
|
||||||
Host = exmpp_jid:prep_domain(From),
|
Host = exmpp_jid:prep_domain(From),
|
||||||
register_iq_response_handler(Host, ID, undefined, F),
|
register_iq_response_handler(Host, ID, undefined, F, Timeout),
|
||||||
exmpp_iq:iq_to_xmlel(IQ#iq{id = ID});
|
exmpp_iq:iq_to_xmlel(IQ#iq{id = ID});
|
||||||
true ->
|
true ->
|
||||||
exmpp_iq:iq_to_xmlel(IQ)
|
exmpp_iq:iq_to_xmlel(IQ)
|
||||||
end,
|
end,
|
||||||
ejabberd_router:route(From, To, Packet).
|
ejabberd_router:route(From, To, Packet).
|
||||||
|
|
||||||
register_iq_response_handler(_Host, ID, Module, Function) ->
|
register_iq_response_handler(Host, ID, Module, Function) ->
|
||||||
TRef = erlang:start_timer(?IQ_TIMEOUT, ejabberd_local, ID),
|
register_iq_response_handler(Host, ID, Module, Function, undefined).
|
||||||
|
|
||||||
|
register_iq_response_handler(_Host, ID, Module, Function, Timeout0) ->
|
||||||
|
Timeout = case Timeout0 of
|
||||||
|
undefined ->
|
||||||
|
?IQ_TIMEOUT;
|
||||||
|
N when is_integer(N), N > 0 ->
|
||||||
|
N
|
||||||
|
end,
|
||||||
|
TRef = erlang:start_timer(Timeout, ejabberd_local, ID),
|
||||||
ets:insert(iq_response, #iq_response{id = ID,
|
ets:insert(iq_response, #iq_response{id = ID,
|
||||||
module = Module,
|
module = Module,
|
||||||
function = Function,
|
function = Function,
|
||||||
|
Loading…
Reference in New Issue
Block a user