mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
Start conversion to exmpp. For now, only direct calls from ejabberd_c2s
are done. Calls through gen_iq_handler aren't. SVN Revision: 1457
This commit is contained in:
parent
574dbbfd08
commit
532e8ee228
@ -1,3 +1,9 @@
|
|||||||
|
2008-07-17 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
|
||||||
|
|
||||||
|
* src/mod_caps.erl, src/ejabberd_c2s.erl: Start conversion to exmpp.
|
||||||
|
For now, only direct calls from ejabberd_c2s are done. Calls through
|
||||||
|
gen_iq_handler aren't.
|
||||||
|
|
||||||
2008-07-15 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
|
2008-07-15 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
|
||||||
|
|
||||||
Merge revisions from 1434 to revision 1444 from trunk.
|
Merge revisions from 1434 to revision 1444 from trunk.
|
||||||
|
@ -1068,11 +1068,9 @@ handle_info({route, FromOld, ToOld, PacketOld}, StateName, StateData) ->
|
|||||||
LFrom = jlib:short_jid(From),
|
LFrom = jlib:short_jid(From),
|
||||||
LBFrom = jlib:short_bare_jid(From),
|
LBFrom = jlib:short_bare_jid(From),
|
||||||
%% Note contact availability
|
%% Note contact availability
|
||||||
% XXX OLD FORMAT: Els are #xmlelement.
|
Els = Packet#xmlel.children,
|
||||||
Els = PacketOld#xmlelement.children,
|
|
||||||
Caps = mod_caps:read_caps(Els),
|
Caps = mod_caps:read_caps(Els),
|
||||||
% XXX OLD FORMAT: From.
|
mod_caps:note_caps(StateData#state.server, From, Caps),
|
||||||
mod_caps:note_caps(StateData#state.server, FromOld, Caps),
|
|
||||||
NewAvailable = case exmpp_presence:get_type(Packet) of
|
NewAvailable = case exmpp_presence:get_type(Packet) of
|
||||||
'unavailable' ->
|
'unavailable' ->
|
||||||
?DICT:erase(LFrom, StateData#state.pres_available);
|
?DICT:erase(LFrom, StateData#state.pres_available);
|
||||||
|
@ -48,8 +48,9 @@
|
|||||||
code_change/3
|
code_change/3
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
-include_lib("exmpp/include/exmpp.hrl").
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
-include("jlib.hrl").
|
|
||||||
|
|
||||||
-define(PROCNAME, ejabberd_mod_caps).
|
-define(PROCNAME, ejabberd_mod_caps).
|
||||||
-define(DICT, dict).
|
-define(DICT, dict).
|
||||||
@ -61,29 +62,26 @@
|
|||||||
disco_requests = ?DICT:new(),
|
disco_requests = ?DICT:new(),
|
||||||
feature_queries = []}).
|
feature_queries = []}).
|
||||||
|
|
||||||
|
% XXX OLD FORMAT: Re-include jlib.hrl (after clean-up).
|
||||||
|
-record(iq, {id = "",
|
||||||
|
type,
|
||||||
|
xmlns = "",
|
||||||
|
lang = "",
|
||||||
|
sub_el}).
|
||||||
|
|
||||||
%% read_caps takes a list of XML elements (the child elements of a
|
%% read_caps takes a list of XML elements (the child elements of a
|
||||||
%% <presence/> stanza) and returns an opaque value representing the
|
%% <presence/> stanza) and returns an opaque value representing the
|
||||||
%% Entity Capabilities contained therein, or the atom nothing if no
|
%% Entity Capabilities contained therein, or the atom nothing if no
|
||||||
%% capabilities are advertised.
|
%% capabilities are advertised.
|
||||||
read_caps(Els) ->
|
read_caps(Els) ->
|
||||||
read_caps(Els, nothing).
|
read_caps(Els, nothing).
|
||||||
read_caps([{xmlelement, "c", Attrs, _Els} | Tail], Result) ->
|
read_caps([#xmlel{ns = ?NS_CAPS, name = 'c'} = El | Tail], _Result) ->
|
||||||
case xml:get_attr_s("xmlns", Attrs) of
|
Node = exmpp_xml:get_attribute(El, 'node'),
|
||||||
?NS_CAPS ->
|
Version = exmpp_xml:get_attribute(El, 'ver'),
|
||||||
Node = xml:get_attr_s("node", Attrs),
|
Exts = string:tokens(exmpp_xml:get_attribute(El, 'ext'), " "),
|
||||||
Version = xml:get_attr_s("ver", Attrs),
|
read_caps(Tail, #caps{node = Node, version = Version, exts = Exts});
|
||||||
Exts = string:tokens(xml:get_attr_s("ext", Attrs), " "),
|
read_caps([#xmlel{ns = ?NS_MUC_USER, name = 'x'} | _Tail], _Result) ->
|
||||||
read_caps(Tail, #caps{node = Node, version = Version, exts = Exts});
|
nothing;
|
||||||
_ ->
|
|
||||||
read_caps(Tail, Result)
|
|
||||||
end;
|
|
||||||
read_caps([{xmlelement, "x", Attrs, _Els} | Tail], Result) ->
|
|
||||||
case xml:get_attr_s("xmlns", Attrs) of
|
|
||||||
?NS_MUC_USER ->
|
|
||||||
nothing;
|
|
||||||
_ ->
|
|
||||||
read_caps(Tail, Result)
|
|
||||||
end;
|
|
||||||
read_caps([_ | Tail], Result) ->
|
read_caps([_ | Tail], Result) ->
|
||||||
read_caps(Tail, Result);
|
read_caps(Tail, Result);
|
||||||
read_caps([], Result) ->
|
read_caps([], Result) ->
|
||||||
@ -210,17 +208,14 @@ handle_cast({note_caps, From,
|
|||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun(SubNode, Dict) ->
|
fun(SubNode, Dict) ->
|
||||||
ID = randoms:get_string(),
|
ID = randoms:get_string(),
|
||||||
Stanza =
|
Query = exmpp_xml:set_attribute(
|
||||||
{xmlelement, "iq",
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'query'},
|
||||||
[{"type", "get"},
|
'node', lists:concat([Node, "#", SubNode])),
|
||||||
{"id", ID}],
|
Stanza = exmpp_iq:get(?NS_JABBER_CLIENT, Query, ID),
|
||||||
[{xmlelement, "query",
|
|
||||||
[{"xmlns", ?NS_DISCO_INFO},
|
|
||||||
{"node", lists:concat([Node, "#", SubNode])}],
|
|
||||||
[]}]},
|
|
||||||
ejabberd_local:register_iq_response_handler
|
ejabberd_local:register_iq_response_handler
|
||||||
(Host, ID, ?MODULE, handle_disco_response),
|
(Host, ID, ?MODULE, handle_disco_response),
|
||||||
ejabberd_router:route(jlib:make_jid("", Host, ""), From, Stanza),
|
ejabberd_router:route(exmpp_jid:make_bare_jid(Host),
|
||||||
|
From, Stanza),
|
||||||
timer:send_after(?CAPS_QUERY_TIMEOUT, self(), {disco_timeout, ID}),
|
timer:send_after(?CAPS_QUERY_TIMEOUT, self(), {disco_timeout, ID}),
|
||||||
?DICT:store(ID, {Node, SubNode}, Dict)
|
?DICT:store(ID, {Node, SubNode}, Dict)
|
||||||
end, Requests, Missing),
|
end, Requests, Missing),
|
||||||
@ -301,7 +296,7 @@ handle_cast(visit_feature_queries, #state{feature_queries = FeatureQueries} = St
|
|||||||
{noreply, State#state{feature_queries = NewFeatureQueries}}.
|
{noreply, State#state{feature_queries = NewFeatureQueries}}.
|
||||||
|
|
||||||
handle_disco_response(From, To, IQ) ->
|
handle_disco_response(From, To, IQ) ->
|
||||||
#jid{lserver = Host} = To,
|
#jid{ldomain = Host} = To,
|
||||||
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
Proc = gen_mod:get_module_proc(Host, ?PROCNAME),
|
||||||
gen_server:cast(Proc, {disco_response, From, To, IQ}).
|
gen_server:cast(Proc, {disco_response, From, To, IQ}).
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user