mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
Improve namespace handling
This commit is contained in:
parent
53209b9ab1
commit
58969fb854
@ -862,10 +862,10 @@ resource_conflict_action(U, S, R) ->
|
||||
|
||||
-spec decode_element(xmlel(), state_name(), state()) -> fsm_transition().
|
||||
decode_element(#xmlel{} = El, StateName, StateData) ->
|
||||
try case xmpp:decode(El, [ignore_els]) of
|
||||
try case xmpp:decode(El, ?NS_CLIENT, [ignore_els]) of
|
||||
#iq{sub_els = [_], type = T} = Pkt when T == set; T == get ->
|
||||
NewPkt = xmpp:decode_els(
|
||||
Pkt,
|
||||
Pkt, ?NS_CLIENT,
|
||||
fun(SubEl) when StateName == session_established ->
|
||||
case xmpp:get_ns(SubEl) of
|
||||
?NS_PRIVACY -> true;
|
||||
@ -873,7 +873,7 @@ decode_element(#xmlel{} = El, StateName, StateData) ->
|
||||
_ -> false
|
||||
end;
|
||||
(SubEl) ->
|
||||
xmpp_codec:is_known_tag(SubEl)
|
||||
xmpp:is_known_tag(SubEl)
|
||||
end),
|
||||
?MODULE:StateName(NewPkt, StateData);
|
||||
Pkt ->
|
||||
@ -1566,7 +1566,7 @@ send_element(StateData, #xmlel{} = El) when StateData#state.xml_socket ->
|
||||
send_element(StateData, #xmlel{} = El) ->
|
||||
send_text(StateData, fxml:element_to_binary(El));
|
||||
send_element(StateData, Pkt) ->
|
||||
send_element(StateData, xmpp:encode(Pkt)).
|
||||
send_element(StateData, xmpp:encode(Pkt, ?NS_CLIENT)).
|
||||
|
||||
-spec send_error(state(), xmlel() | stanza(), stanza_error()) -> ok.
|
||||
send_error(StateData, Stanza, Error) ->
|
||||
|
@ -440,11 +440,11 @@ process_user_el(#xmlel{name = Name, attrs = Attrs, children = Els} = El,
|
||||
process_private(xmpp:decode(El), State);
|
||||
{<<"vCard">>, ?NS_VCARD} ->
|
||||
process_vcard(El, State);
|
||||
{<<"offline-messages">>, _} ->
|
||||
Msgs = [xmpp:decode(E, [ignore_els]) || E <- Els],
|
||||
{<<"offline-messages">>, NS} ->
|
||||
Msgs = [xmpp:decode(E, NS, [ignore_els]) || E <- Els],
|
||||
process_offline_msgs(Msgs, State);
|
||||
{<<"presence">>, <<"jabber:client">>} ->
|
||||
process_presence(xmpp:decode(El, [ignore_els]), State);
|
||||
{<<"presence">>, ?NS_CLIENT} ->
|
||||
process_presence(xmpp:decode(El, ?NS_CLIENT, [ignore_els]), State);
|
||||
_ ->
|
||||
{ok, State}
|
||||
end
|
||||
|
@ -253,7 +253,7 @@ process_iq(From, To, #iq{} = IQ) ->
|
||||
ejabberd_sm:process_iq(From, To, IQ)
|
||||
end;
|
||||
process_iq(From, To, El) ->
|
||||
try xmpp:decode(El, [ignore_els]) of
|
||||
try xmpp:decode(El, ?NS_CLIENT, [ignore_els]) of
|
||||
IQ -> process_iq(From, To, IQ)
|
||||
catch _:{xmpp_codec, Why} ->
|
||||
Type = xmpp:get_type(El),
|
||||
@ -390,7 +390,7 @@ do_route(OrigFrom, OrigTo, OrigPacket) ->
|
||||
LDstDomain = To#jid.lserver,
|
||||
case mnesia:dirty_read(route, LDstDomain) of
|
||||
[] ->
|
||||
try xmpp:decode(Packet, [ignore_els]) of
|
||||
try xmpp:decode(Packet, ?NS_CLIENT, [ignore_els]) of
|
||||
Pkt ->
|
||||
ejabberd_s2s:route(From, To, Pkt)
|
||||
catch _:{xmpp_codec, Why} ->
|
||||
@ -422,7 +422,7 @@ do_route(OrigFrom, OrigTo, OrigPacket) ->
|
||||
-spec do_route(jid(), jid(), xmlel() | xmpp_element(), #route{}) -> any().
|
||||
do_route(From, To, Packet, #route{local_hint = LocalHint,
|
||||
pid = Pid}) when is_pid(Pid) ->
|
||||
try xmpp:decode(Packet, [ignore_els]) of
|
||||
try xmpp:decode(Packet, ?NS_CLIENT, [ignore_els]) of
|
||||
Pkt ->
|
||||
case LocalHint of
|
||||
{apply, Module, Function} when node(Pid) == node() ->
|
||||
|
@ -557,7 +557,7 @@ send_text(StateData, Text) ->
|
||||
|
||||
-spec send_element(state(), xmpp_element()) -> ok.
|
||||
send_element(StateData, El) ->
|
||||
El1 = fix_ns(xmpp:encode(El)),
|
||||
El1 = xmpp:encode(El, ?NS_SERVER),
|
||||
send_text(StateData, fxml:element_to_binary(El1)).
|
||||
|
||||
-spec send_error(state(), xmlel() | stanza(), stanza_error()) -> ok.
|
||||
@ -591,20 +591,6 @@ change_shaper(StateData, Host, JID) ->
|
||||
(StateData#state.sockmod):change_shaper(StateData#state.socket,
|
||||
Shaper).
|
||||
|
||||
-spec fix_ns(xmlel()) -> xmlel().
|
||||
fix_ns(#xmlel{name = Name} = El) when Name == <<"message">>;
|
||||
Name == <<"iq">>;
|
||||
Name == <<"presence">>;
|
||||
Name == <<"db:verify">>,
|
||||
Name == <<"db:result">> ->
|
||||
Attrs = lists:filter(
|
||||
fun({<<"xmlns">>, _}) -> false;
|
||||
(_) -> true
|
||||
end, El#xmlel.attrs),
|
||||
El#xmlel{attrs = Attrs};
|
||||
fix_ns(El) ->
|
||||
El.
|
||||
|
||||
-spec new_id() -> binary().
|
||||
new_id() -> randoms:get_string().
|
||||
|
||||
@ -632,7 +618,7 @@ decode_element(#xmlel{} = El, StateName, StateData) ->
|
||||
true ->
|
||||
[]
|
||||
end,
|
||||
try xmpp:decode(El, Opts) of
|
||||
try xmpp:decode(El, ?NS_SERVER, Opts) of
|
||||
Pkt -> ?MODULE:StateName(Pkt, StateData)
|
||||
catch error:{xmpp_codec, Why} ->
|
||||
case xmpp:is_stanza(El) of
|
||||
|
@ -740,7 +740,7 @@ send_text(StateData, Text) ->
|
||||
|
||||
-spec send_element(state(), xmpp_element()) -> ok.
|
||||
send_element(StateData, El) ->
|
||||
El1 = fix_ns(xmpp:encode(El)),
|
||||
El1 = xmpp:encode(El, ?NS_SERVER),
|
||||
send_text(StateData, fxml:element_to_binary(El1)).
|
||||
|
||||
-spec send_header(state(), undefined | {integer(), integer()}) -> ok.
|
||||
@ -766,20 +766,6 @@ send_queue(StateData, Q) ->
|
||||
{empty, _Q1} -> ok
|
||||
end.
|
||||
|
||||
-spec fix_ns(xmlel()) -> xmlel().
|
||||
fix_ns(#xmlel{name = Name} = El) when Name == <<"message">>;
|
||||
Name == <<"iq">>;
|
||||
Name == <<"presence">>;
|
||||
Name == <<"db:verify">>,
|
||||
Name == <<"db:result">> ->
|
||||
Attrs = lists:filter(
|
||||
fun({<<"xmlns">>, _}) -> false;
|
||||
(_) -> true
|
||||
end, El#xmlel.attrs),
|
||||
El#xmlel{attrs = Attrs};
|
||||
fix_ns(El) ->
|
||||
El.
|
||||
|
||||
%% Bounce a single message (xmlelement)
|
||||
-spec bounce_element(stanza(), stanza_error()) -> ok.
|
||||
bounce_element(El, Error) ->
|
||||
@ -1083,7 +1069,12 @@ fsm_limit_opts() ->
|
||||
|
||||
-spec decode_element(xmlel(), state_name(), state()) -> fsm_next().
|
||||
decode_element(#xmlel{} = El, StateName, StateData) ->
|
||||
try xmpp:decode(El) of
|
||||
Opts = if StateName == stream_established ->
|
||||
[ignore_els];
|
||||
true ->
|
||||
[]
|
||||
end,
|
||||
try xmpp:decode(El, ?NS_SERVER, Opts) of
|
||||
Pkt -> ?MODULE:StateName(Pkt, StateData)
|
||||
catch error:{xmpp_codec, Why} ->
|
||||
Type = xmpp:get_type(El),
|
||||
|
@ -308,7 +308,7 @@ send_text(StateData, Text) ->
|
||||
|
||||
-spec send_element(state(), xmpp_element()) -> ok.
|
||||
send_element(StateData, El) ->
|
||||
El1 = fix_ns(xmpp:encode(El)),
|
||||
El1 = xmpp:encode(El, ?NS_COMPONENT),
|
||||
send_text(StateData, fxml:element_to_binary(El1)).
|
||||
|
||||
-spec send_error(state(), xmlel() | stanza(), stanza_error()) -> ok.
|
||||
@ -334,21 +334,9 @@ send_header(StateData, Host) ->
|
||||
send_trailer(StateData) ->
|
||||
send_text(StateData, <<"</stream:stream>">>).
|
||||
|
||||
-spec fix_ns(xmlel()) -> xmlel().
|
||||
fix_ns(#xmlel{name = Name} = El) when Name == <<"message">>;
|
||||
Name == <<"iq">>;
|
||||
Name == <<"presence">> ->
|
||||
Attrs = lists:filter(
|
||||
fun({<<"xmlns">>, _}) -> false;
|
||||
(_) -> true
|
||||
end, El#xmlel.attrs),
|
||||
El#xmlel{attrs = Attrs};
|
||||
fix_ns(El) ->
|
||||
El.
|
||||
|
||||
-spec decode_element(xmlel(), state_name(), state()) -> fsm_transition().
|
||||
decode_element(#xmlel{} = El, StateName, StateData) ->
|
||||
try xmpp:decode(El, [ignore_els]) of
|
||||
try xmpp:decode(El, ?NS_COMPONENT, [ignore_els]) of
|
||||
Pkt -> ?MODULE:StateName(Pkt, StateData)
|
||||
catch error:{xmpp_codec, Why} ->
|
||||
case xmpp:is_stanza(El) of
|
||||
|
@ -144,7 +144,7 @@ process_iq(_Host, Module, Function, From, To, IQ0) ->
|
||||
end
|
||||
catch E:R ->
|
||||
?ERROR_MSG("failed to process iq:~n~s~nReason = ~p",
|
||||
[xmpp_codec:pp(IQ), {E, {R, erlang:get_stacktrace()}}]),
|
||||
[xmpp:pp(IQ), {E, {R, erlang:get_stacktrace()}}]),
|
||||
Txt = <<"Module failed to handle the query">>,
|
||||
Err = xmpp:err_internal_server_error(Txt, IQ#iq.lang),
|
||||
ejabberd_router:route(To, From, xmpp:make_error(IQ, Err))
|
||||
@ -169,7 +169,7 @@ process_iq(Module, Function, #iq{lang = Lang, sub_els = [El]} = IQ) ->
|
||||
process_iq(Module, Function, From, To, IQ) ->
|
||||
case Module:Function(From, To, IQ) of
|
||||
ignore -> ignore;
|
||||
ResIQ -> xmpp:decode(jlib:iq_to_xml(ResIQ), [ignore_els])
|
||||
ResIQ -> xmpp:decode(jlib:iq_to_xml(ResIQ), ?NS_CLIENT, [ignore_els])
|
||||
end.
|
||||
|
||||
-spec check_type(type()) -> type().
|
||||
|
@ -155,7 +155,7 @@ process_offline(Server, To, #xmlel{children = Els}) ->
|
||||
LServer = jid:nameprep(Server),
|
||||
lists:foreach(
|
||||
fun(#xmlel{} = El) ->
|
||||
try xmpp:decode(El, [ignore_els]) of
|
||||
try xmpp:decode(El, ?NS_CLIENT, [ignore_els]) of
|
||||
#message{from = JID} ->
|
||||
From = case JID of
|
||||
undefined -> jid:make(Server);
|
||||
|
@ -1351,7 +1351,7 @@ send_stanza(FromString, ToString, Stanza) ->
|
||||
#xmlel{} = El = fxml_stream:parse_element(Stanza),
|
||||
#jid{} = From = jid:from_string(FromString),
|
||||
#jid{} = To = jid:to_string(ToString),
|
||||
Pkt = xmpp:decode(El, [ignore_els]),
|
||||
Pkt = xmpp:decode(El, ?NS_CLIENT, [ignore_els]),
|
||||
ejabberd_router:route(From, To, Pkt)
|
||||
catch _:{xmpp_codec, Why} ->
|
||||
io:format("incorrect stanza: ~s~n", [xmpp:format_error(Why)]),
|
||||
|
@ -768,7 +768,7 @@ send_motd(#jid{luser = LUser, lserver = LServer} = JID) when LUser /= <<>> ->
|
||||
Mod = gen_mod:db_mod(LServer, ?MODULE),
|
||||
case Mod:get_motd(LServer) of
|
||||
{ok, Packet} ->
|
||||
try xmpp:decode(Packet, [ignore_els]) of
|
||||
try xmpp:decode(Packet, ?NS_CLIENT, [ignore_els]) of
|
||||
Msg ->
|
||||
case Mod:is_motd_user(LUser, LServer) of
|
||||
false ->
|
||||
@ -792,7 +792,7 @@ get_stored_motd(LServer) ->
|
||||
Mod = gen_mod:db_mod(LServer, ?MODULE),
|
||||
case Mod:get_motd(LServer) of
|
||||
{ok, Packet} ->
|
||||
try xmpp:decode(Packet, [ignore_els]) of
|
||||
try xmpp:decode(Packet, ?NS_CLIENT, [ignore_els]) of
|
||||
#message{body = Body, subject = Subject} ->
|
||||
{xmpp:get_text(Subject), xmpp:get_text(Body)}
|
||||
catch _:{xmpp_codec, Why} ->
|
||||
|
@ -540,18 +540,20 @@ should_archive(#message{body = Body} = Pkt, LServer) ->
|
||||
should_archive(_, _LServer) ->
|
||||
false.
|
||||
|
||||
-spec strip_my_archived_tag(stanza(), binary()) -> stanza().
|
||||
strip_my_archived_tag(Pkt, LServer) ->
|
||||
NewPkt = xmpp:decode_els(
|
||||
Pkt, fun(El) ->
|
||||
case xmpp:get_name(El) of
|
||||
<<"archived">> ->
|
||||
xmpp:get_ns(El) == ?NS_MAM_TMP;
|
||||
<<"stanza-id">> ->
|
||||
xmpp:get_ns(El) == ?NS_SID_0;
|
||||
_ ->
|
||||
false
|
||||
end
|
||||
end),
|
||||
Pkt, ?NS_CLIENT,
|
||||
fun(El) ->
|
||||
case xmpp:get_name(El) of
|
||||
<<"archived">> ->
|
||||
xmpp:get_ns(El) == ?NS_MAM_TMP;
|
||||
<<"stanza-id">> ->
|
||||
xmpp:get_ns(El) == ?NS_SID_0;
|
||||
_ ->
|
||||
false
|
||||
end
|
||||
end),
|
||||
NewEls = lists:filter(
|
||||
fun(#mam_archived{by = #jid{luser = <<>>} = By}) ->
|
||||
By#jid.lserver /= LServer;
|
||||
@ -564,19 +566,20 @@ strip_my_archived_tag(Pkt, LServer) ->
|
||||
|
||||
strip_x_jid_tags(Pkt) ->
|
||||
NewPkt = xmpp:decode_els(
|
||||
Pkt, fun(El) ->
|
||||
case xmpp:get_name(El) of
|
||||
<<"x">> ->
|
||||
case xmpp:get_ns(El) of
|
||||
?NS_MUC_USER -> true;
|
||||
?NS_MUC_ADMIN -> true;
|
||||
?NS_MUC_OWNER -> true;
|
||||
_ -> false
|
||||
end;
|
||||
_ ->
|
||||
false
|
||||
end
|
||||
end),
|
||||
Pkt, ?NS_CLIENT,
|
||||
fun(El) ->
|
||||
case xmpp:get_name(El) of
|
||||
<<"x">> ->
|
||||
case xmpp:get_ns(El) of
|
||||
?NS_MUC_USER -> true;
|
||||
?NS_MUC_ADMIN -> true;
|
||||
?NS_MUC_OWNER -> true;
|
||||
_ -> false
|
||||
end;
|
||||
_ ->
|
||||
false
|
||||
end
|
||||
end),
|
||||
NewEls = lists:filter(
|
||||
fun(El) ->
|
||||
Items = case El of
|
||||
@ -836,7 +839,7 @@ msg_to_el(#archive_msg{timestamp = TS, packet = Pkt1, nick = Nick, peer = Peer},
|
||||
|
||||
maybe_update_from_to(#xmlel{} = El, JidRequestor, JidArchive, Peer,
|
||||
{groupchat, _, _} = MsgType, Nick) ->
|
||||
Pkt = xmpp:decode(El, [ignore_els]),
|
||||
Pkt = xmpp:decode(El, ?NS_CLIENT, [ignore_els]),
|
||||
maybe_update_from_to(Pkt, JidRequestor, JidArchive, Peer, MsgType, Nick);
|
||||
maybe_update_from_to(#message{sub_els = Els} = Pkt, JidRequestor, JidArchive,
|
||||
Peer, {groupchat, Role,
|
||||
|
@ -4343,7 +4343,7 @@ tab_count_user(JID) ->
|
||||
|
||||
-spec element_size(stanza()) -> non_neg_integer().
|
||||
element_size(El) ->
|
||||
byte_size(fxml:element_to_binary(xmpp:encode(El))).
|
||||
byte_size(fxml:element_to_binary(xmpp:encode(El, ?NS_CLIENT))).
|
||||
|
||||
-spec store_room(state()) -> ok.
|
||||
store_room(StateData) ->
|
||||
|
@ -611,7 +611,7 @@ get_offline_els(LUser, LServer) ->
|
||||
end, Hdrs).
|
||||
|
||||
offline_msg_to_route(LServer, #offline_msg{} = R) ->
|
||||
Pkt = xmpp:decode(R#offline_msg.packet, [ignore_els]),
|
||||
Pkt = xmpp:decode(R#offline_msg.packet, ?NS_CLIENT, [ignore_els]),
|
||||
Pkt1 = case R#offline_msg.timestamp of
|
||||
undefined ->
|
||||
Pkt;
|
||||
@ -626,7 +626,7 @@ read_message_headers(LUser, LServer) ->
|
||||
lists:map(
|
||||
fun({Seq, From, To, El}) ->
|
||||
Node = integer_to_binary(Seq),
|
||||
Packet = xmpp:decode(El, [ignore_els]),
|
||||
Packet = xmpp:decode(El, ?NS_CLIENT, [ignore_els]),
|
||||
{Node, From, To, Packet}
|
||||
end, Mod:read_message_headers(LUser, LServer)).
|
||||
|
||||
|
60
src/xmpp.erl
60
src/xmpp.erl
@ -10,14 +10,15 @@
|
||||
|
||||
%% API
|
||||
-export([make_iq_result/1, make_iq_result/2, make_error/2,
|
||||
decode/1, decode/2, encode/1,
|
||||
decode/1, decode/3, encode/1, encode/2,
|
||||
get_type/1, get_to/1, get_from/1, get_id/1,
|
||||
get_lang/1, get_error/1, get_els/1, get_ns/1,
|
||||
set_type/2, set_to/2, set_from/2, set_id/2,
|
||||
set_lang/2, set_error/2, set_els/2, set_from_to/3,
|
||||
format_error/1, is_stanza/1, set_subtag/2, get_subtag/2,
|
||||
remove_subtag/2, has_subtag/2, decode_els/1, decode_els/2,
|
||||
pp/1, get_name/1, get_text/1, mk_text/1, mk_text/2]).
|
||||
remove_subtag/2, has_subtag/2, decode_els/1, decode_els/3,
|
||||
pp/1, get_name/1, get_text/1, mk_text/1, mk_text/2,
|
||||
is_known_tag/1, is_known_tag/2]).
|
||||
|
||||
%% XMPP errors
|
||||
-export([err_bad_request/0, err_bad_request/2,
|
||||
@ -117,7 +118,7 @@ make_error(#xmlel{attrs = Attrs, children = Els} = El, Err) ->
|
||||
Attrs
|
||||
end,
|
||||
Attrs3 = lists:keystore(<<"type">>, 1, Attrs2, {<<"type">>, <<"error">>}),
|
||||
El#xmlel{attrs = Attrs3, children = Els ++ [encode(Err)]}.
|
||||
El#xmlel{attrs = Attrs3, children = Els ++ [encode(Err, ?NS_CLIENT)]}.
|
||||
|
||||
-spec get_id(iq() | message() | presence() | xmlel()) -> binary().
|
||||
get_id(#iq{id = ID}) -> ID;
|
||||
@ -232,35 +233,30 @@ get_name(Pkt) ->
|
||||
|
||||
-spec decode(xmlel() | xmpp_element()) -> {ok, xmpp_element()} | {error, any()}.
|
||||
decode(El) ->
|
||||
decode(El, []).
|
||||
decode(El, ?NS_CLIENT, []).
|
||||
|
||||
-spec decode(xmlel() | xmpp_element(),
|
||||
[proplists:property()] |
|
||||
fun((xmlel() | xmpp_element()) -> boolean())) ->
|
||||
-spec decode(xmlel() | xmpp_element(), binary(), [proplists:property()]) ->
|
||||
{ok, xmpp_element()} | {error, any()}.
|
||||
decode(#xmlel{} = El, MatchFun) when is_function(MatchFun) ->
|
||||
Pkt = xmpp_codec:decode(add_ns(El), [ignore_els]),
|
||||
decode_els(Pkt, MatchFun);
|
||||
decode(#xmlel{} = El, Opts) when is_list(Opts) ->
|
||||
xmpp_codec:decode(add_ns(El), Opts);
|
||||
decode(Pkt, _Opts) ->
|
||||
decode(#xmlel{} = El, TopXMLNS, Opts) ->
|
||||
xmpp_codec:decode(El, TopXMLNS, Opts);
|
||||
decode(Pkt, _, _) ->
|
||||
Pkt.
|
||||
|
||||
-spec decode_els(iq()) -> iq();
|
||||
(message()) -> message();
|
||||
(presence()) -> presence().
|
||||
decode_els(Stanza) ->
|
||||
decode_els(Stanza, fun xmpp_codec:is_known_tag/1).
|
||||
decode_els(Stanza, ?NS_CLIENT, fun is_known_tag/1).
|
||||
|
||||
-type match_fun() :: fun((xmlel()) -> boolean()).
|
||||
-spec decode_els(iq(), match_fun()) -> iq();
|
||||
(message(), match_fun()) -> message();
|
||||
(presence(), match_fun()) -> presence().
|
||||
decode_els(Stanza, MatchFun) ->
|
||||
-spec decode_els(iq(), binary(), match_fun()) -> iq();
|
||||
(message(), binary(), match_fun()) -> message();
|
||||
(presence(), binary(), match_fun()) -> presence().
|
||||
decode_els(Stanza, TopXMLNS, MatchFun) ->
|
||||
Els = lists:map(
|
||||
fun(#xmlel{} = El) ->
|
||||
case MatchFun(El) of
|
||||
true -> decode(El);
|
||||
true -> decode(El, TopXMLNS, []);
|
||||
false -> El
|
||||
end;
|
||||
(Pkt) ->
|
||||
@ -270,7 +266,19 @@ decode_els(Stanza, MatchFun) ->
|
||||
|
||||
-spec encode(xmpp_element() | xmlel()) -> xmlel().
|
||||
encode(Pkt) ->
|
||||
xmpp_codec:encode(Pkt).
|
||||
encode(Pkt, <<>>).
|
||||
|
||||
-spec encode(xmpp_element() | xmlel(), binary()) -> xmlel().
|
||||
encode(Pkt, TopXMLNS) ->
|
||||
xmpp_codec:encode(Pkt, TopXMLNS).
|
||||
|
||||
-spec is_known_tag(xmlel()) -> boolean().
|
||||
is_known_tag(El) ->
|
||||
is_known_tag(El, ?NS_CLIENT).
|
||||
|
||||
-spec is_known_tag(xmlel(), binary()) -> boolean().
|
||||
is_known_tag(El, TopXMLNS) ->
|
||||
xmpp_codec:is_known_tag(El, TopXMLNS).
|
||||
|
||||
format_error(Reason) ->
|
||||
xmpp_codec:format_error(Reason).
|
||||
@ -809,16 +817,6 @@ serr(Reason, Text, Lang) ->
|
||||
text = #text{lang = Lang,
|
||||
data = translate:translate(Lang, Text)}}.
|
||||
|
||||
-spec add_ns(xmlel()) -> xmlel().
|
||||
add_ns(#xmlel{name = Name} = El) when Name == <<"message">>;
|
||||
Name == <<"presence">>;
|
||||
Name == <<"iq">> ->
|
||||
Attrs = lists:keystore(<<"xmlns">>, 1, El#xmlel.attrs,
|
||||
{<<"xmlns">>, ?NS_CLIENT}),
|
||||
El#xmlel{attrs = Attrs};
|
||||
add_ns(El) ->
|
||||
El.
|
||||
|
||||
-spec match_tag(xmlel() | xmpp_element(), binary(), binary()) -> boolean().
|
||||
match_tag(El, TagName, XMLNS) ->
|
||||
get_name(El) == TagName andalso get_ns(El) == XMLNS.
|
||||
|
12218
src/xmpp_codec.erl
12218
src/xmpp_codec.erl
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,7 @@
|
||||
-compile(export_all).
|
||||
|
||||
-import(suite, [init_config/1, connect/1, disconnect/1,
|
||||
recv/0, send/2, send_recv/2, my_jid/1, server_jid/1,
|
||||
recv/1, send/2, send_recv/2, my_jid/1, server_jid/1,
|
||||
pubsub_jid/1, proxy_jid/1, muc_jid/1, muc_room_jid/1,
|
||||
mix_jid/1, mix_room_jid/1, get_features/2, re_register/1,
|
||||
is_feature_advertised/2, subscribe_to_events/1,
|
||||
@ -974,7 +974,7 @@ sm_resume(Config) ->
|
||||
Txt = #text{data = <<"body">>},
|
||||
Msg = #message{from = ServerJID, to = MyJID, body = [Txt]},
|
||||
%% Route message. The message should be queued by the C2S process.
|
||||
ejabberd_router:route(ServerJID, MyJID, xmpp_codec:encode(Msg)),
|
||||
ejabberd_router:route(ServerJID, MyJID, Msg),
|
||||
send(Config, #sm_resume{previd = ID, h = 0, xmlns = ?NS_STREAM_MGMT_3}),
|
||||
?recv1(#sm_resumed{previd = ID, h = 3}),
|
||||
?recv1(#message{from = ServerJID, to = MyJID, body = [Txt]}),
|
||||
@ -1001,7 +1001,7 @@ private(Config) ->
|
||||
<<"some.conference.org">>,
|
||||
<<>>)},
|
||||
Storage = #bookmark_storage{conference = [Conference]},
|
||||
StorageXMLOut = xmpp_codec:encode(Storage),
|
||||
StorageXMLOut = xmpp:encode(Storage),
|
||||
WrongEl = #xmlel{name = <<"wrong">>},
|
||||
#iq{type = error} =
|
||||
send_recv(Config, #iq{type = get,
|
||||
@ -1015,9 +1015,9 @@ private(Config) ->
|
||||
send_recv(
|
||||
Config,
|
||||
#iq{type = get,
|
||||
sub_els = [#private{xml_els = [xmpp_codec:encode(
|
||||
sub_els = [#private{xml_els = [xmpp:encode(
|
||||
#bookmark_storage{})]}]}),
|
||||
Storage = xmpp_codec:decode(StorageXMLIn),
|
||||
Storage = xmpp:decode(StorageXMLIn),
|
||||
disconnect(Config).
|
||||
|
||||
last(Config) ->
|
||||
@ -1221,7 +1221,7 @@ pubsub(Config) ->
|
||||
ItemID = randoms:get_string(),
|
||||
Node = <<"presence!@#$%^&*()'\"`~<>+-/;:_=[]{}|\\">>,
|
||||
Item = #ps_item{id = ItemID,
|
||||
xml_els = [xmpp_codec:encode(#presence{})]},
|
||||
xml_els = [xmpp:encode(#presence{})]},
|
||||
#iq{type = result,
|
||||
sub_els = [#pubsub{publish = #ps_publish{
|
||||
node = Node,
|
||||
@ -1320,10 +1320,10 @@ mix_master(Config) ->
|
||||
?recv2(#iq{type = result, id = I0,
|
||||
sub_els = [#mix_join{subscribe = Nodes, jid = MyBareJID}]},
|
||||
#message{from = Room}),
|
||||
#mix_participant{jid = MyBareJID} = xmpp_codec:decode(PXML),
|
||||
#mix_participant{jid = MyBareJID} = xmpp:decode(PXML),
|
||||
%% Coming online
|
||||
PresenceID = randoms:get_string(),
|
||||
Presence = xmpp_codec:encode(#presence{}),
|
||||
Presence = xmpp:encode(#presence{}),
|
||||
I1 = send(
|
||||
Config,
|
||||
#iq{type = set, to = Room,
|
||||
@ -1355,7 +1355,7 @@ mix_master(Config) ->
|
||||
sub_els = [#ps_event{
|
||||
items = #ps_items{
|
||||
node = ?NS_MIX_NODES_PRESENCE,
|
||||
retract = PresenceID}}]} = recv(),
|
||||
retract = PresenceID}}]} = recv(Config),
|
||||
%% Leaving
|
||||
I2 = send(Config, #iq{type = set, to = Room, sub_els = [#mix_leave{}]}),
|
||||
?recv2(#iq{type = result, id = I2, sub_els = []},
|
||||
@ -2367,7 +2367,7 @@ mam_query_all(Config, NS) ->
|
||||
_ -> set
|
||||
end,
|
||||
I = send(Config, #iq{type = Type, sub_els = [#mam_query{xmlns = NS, id = QID}]}),
|
||||
maybe_recv_iq_result(NS, I),
|
||||
maybe_recv_iq_result(Config, NS, I),
|
||||
Iter = if NS == ?NS_MAM_TMP -> lists:seq(1, 5);
|
||||
true -> lists:seq(1, 5) ++ lists:seq(1, 5)
|
||||
end,
|
||||
@ -2408,7 +2408,7 @@ mam_query_with(Config, JID, NS) ->
|
||||
Iter = if NS == ?NS_MAM_TMP -> lists:seq(1, 5);
|
||||
true -> lists:seq(1, 5) ++ lists:seq(1, 5)
|
||||
end,
|
||||
maybe_recv_iq_result(NS, I),
|
||||
maybe_recv_iq_result(Config, NS, I),
|
||||
lists:foreach(
|
||||
fun(N) ->
|
||||
Text = #text{data = integer_to_binary(N)},
|
||||
@ -2430,9 +2430,9 @@ mam_query_with(Config, JID, NS) ->
|
||||
?recv1(#message{sub_els = [#mam_fin{complete = true}]})
|
||||
end.
|
||||
|
||||
maybe_recv_iq_result(?NS_MAM_0, I1) ->
|
||||
maybe_recv_iq_result(Config, ?NS_MAM_0, I1) ->
|
||||
?recv1(#iq{type = result, id = I1});
|
||||
maybe_recv_iq_result(_, _) ->
|
||||
maybe_recv_iq_result(_, _, _) ->
|
||||
ok.
|
||||
|
||||
mam_query_rsm(Config, NS) ->
|
||||
@ -2446,7 +2446,7 @@ mam_query_rsm(Config, NS) ->
|
||||
I1 = send(Config,
|
||||
#iq{type = Type,
|
||||
sub_els = [#mam_query{xmlns = NS, rsm = #rsm_set{max = 3}}]}),
|
||||
maybe_recv_iq_result(NS, I1),
|
||||
maybe_recv_iq_result(Config, NS, I1),
|
||||
lists:foreach(
|
||||
fun(N) ->
|
||||
Text = #text{data = integer_to_binary(N)},
|
||||
@ -2478,7 +2478,7 @@ mam_query_rsm(Config, NS) ->
|
||||
sub_els = [#mam_query{xmlns = NS,
|
||||
rsm = #rsm_set{max = 2,
|
||||
'after' = Last}}]}),
|
||||
maybe_recv_iq_result(NS, I2),
|
||||
maybe_recv_iq_result(Config, NS, I2),
|
||||
lists:foreach(
|
||||
fun(N) ->
|
||||
Text = #text{data = integer_to_binary(N)},
|
||||
@ -2515,7 +2515,7 @@ mam_query_rsm(Config, NS) ->
|
||||
sub_els = [#mam_query{xmlns = NS,
|
||||
rsm = #rsm_set{max = 3,
|
||||
before = First}}]}),
|
||||
maybe_recv_iq_result(NS, I3),
|
||||
maybe_recv_iq_result(Config, NS, I3),
|
||||
lists:foreach(
|
||||
fun(N) ->
|
||||
Text = #text{data = integer_to_binary(N)},
|
||||
@ -2544,7 +2544,7 @@ mam_query_rsm(Config, NS) ->
|
||||
#iq{type = Type,
|
||||
sub_els = [#mam_query{xmlns = NS,
|
||||
rsm = #rsm_set{max = 0}}]}),
|
||||
maybe_recv_iq_result(NS, I4),
|
||||
maybe_recv_iq_result(Config, NS, I4),
|
||||
if NS == ?NS_MAM_TMP ->
|
||||
?recv1(#iq{type = result, id = I4,
|
||||
sub_els = [#mam_query{
|
||||
@ -2566,7 +2566,7 @@ mam_query_rsm(Config, NS) ->
|
||||
sub_els = [#mam_query{xmlns = NS,
|
||||
rsm = #rsm_set{max = 2,
|
||||
before = <<"">>}}]}),
|
||||
maybe_recv_iq_result(NS, I5),
|
||||
maybe_recv_iq_result(Config, NS, I5),
|
||||
lists:foreach(
|
||||
fun(N) ->
|
||||
Text = #text{data = integer_to_binary(N)},
|
||||
@ -2598,7 +2598,7 @@ client_state_master(Config) ->
|
||||
ChatState = #message{to = Peer, thread = <<"1">>,
|
||||
sub_els = [#chatstate{type = active}]},
|
||||
Message = ChatState#message{body = [#text{data = <<"body">>}]},
|
||||
PepPayload = xmpp_codec:encode(#presence{}),
|
||||
PepPayload = xmpp:encode(#presence{}),
|
||||
PepOne = #message{
|
||||
to = Peer,
|
||||
sub_els =
|
||||
@ -2661,7 +2661,7 @@ client_state_slave(Config) ->
|
||||
items =
|
||||
[#ps_item{
|
||||
id = <<"pep-1">>}]}},
|
||||
#delay{}]} = recv(),
|
||||
#delay{}]} = recv(Config),
|
||||
#message{
|
||||
from = Peer,
|
||||
sub_els =
|
||||
@ -2672,7 +2672,7 @@ client_state_slave(Config) ->
|
||||
items =
|
||||
[#ps_item{
|
||||
id = <<"pep-2">>}]}},
|
||||
#delay{}]} = recv(),
|
||||
#delay{}]} = recv(Config),
|
||||
?recv1(#message{from = Peer, thread = <<"1">>,
|
||||
sub_els = [#chatstate{type = composing},
|
||||
#delay{}]}),
|
||||
|
@ -184,11 +184,11 @@ init_stream(Config) ->
|
||||
component -> ?NS_COMPONENT;
|
||||
server -> ?NS_SERVER
|
||||
end,
|
||||
#stream_start{id = ID, xmlns = XMLNS, version = Version} = recv(),
|
||||
#stream_start{id = ID, xmlns = XMLNS, version = Version} = recv(Config),
|
||||
set_opt(stream_id, ID, NewConfig).
|
||||
|
||||
process_stream_features(Config) ->
|
||||
#stream_features{sub_els = Fs} = recv(),
|
||||
#stream_features{sub_els = Fs} = recv(Config),
|
||||
Mechs = lists:flatmap(
|
||||
fun(#sasl_mechanisms{list = Ms}) ->
|
||||
Ms;
|
||||
@ -213,7 +213,7 @@ disconnect(Config) ->
|
||||
catch exit:normal ->
|
||||
ok
|
||||
end,
|
||||
{xmlstreamend, <<"stream:stream">>} = recv(),
|
||||
{xmlstreamend, <<"stream:stream">>} = recv(Config),
|
||||
ejabberd_socket:close(Socket),
|
||||
Config.
|
||||
|
||||
@ -227,7 +227,7 @@ starttls(Config) ->
|
||||
|
||||
starttls(Config, ShouldFail) ->
|
||||
send(Config, #starttls{}),
|
||||
case recv() of
|
||||
case recv(Config) of
|
||||
#starttls_proceed{} when ShouldFail ->
|
||||
ct:fail(starttls_should_have_failed);
|
||||
#starttls_failure{} when ShouldFail ->
|
||||
@ -244,7 +244,7 @@ starttls(Config, ShouldFail) ->
|
||||
|
||||
zlib(Config) ->
|
||||
send(Config, #compress{methods = [<<"zlib">>]}),
|
||||
#compressed{} = recv(),
|
||||
#compressed{} = recv(Config),
|
||||
ZlibSocket = ejabberd_socket:compress(?config(socket, Config)),
|
||||
process_stream_features(init_stream(set_opt(socket, ZlibSocket, Config))).
|
||||
|
||||
@ -346,7 +346,7 @@ auth_component(Config, ShouldFail) ->
|
||||
Password = ?config(password, Config),
|
||||
Digest = p1_sha:sha(<<StreamID/binary, Password/binary>>),
|
||||
send(Config, #handshake{data = Digest}),
|
||||
case recv() of
|
||||
case recv(Config) of
|
||||
#handshake{} when ShouldFail ->
|
||||
ct:fail(component_auth_should_have_failed);
|
||||
#handshake{} ->
|
||||
@ -369,7 +369,7 @@ auth_SASL(Mech, Config, ShouldFail) ->
|
||||
wait_auth_SASL_result(set_opt(sasl, SASL, Config), ShouldFail).
|
||||
|
||||
wait_auth_SASL_result(Config, ShouldFail) ->
|
||||
case recv() of
|
||||
case recv(Config) of
|
||||
#sasl_success{} when ShouldFail ->
|
||||
ct:fail(sasl_auth_should_have_failed);
|
||||
#sasl_success{} ->
|
||||
@ -379,8 +379,8 @@ wait_auth_SASL_result(Config, ShouldFail) ->
|
||||
NS = if Type == client -> ?NS_CLIENT;
|
||||
Type == server -> ?NS_SERVER
|
||||
end,
|
||||
#stream_start{xmlns = NS, version = {1,0}} = recv(),
|
||||
#stream_features{sub_els = Fs} = recv(),
|
||||
#stream_start{xmlns = NS, version = {1,0}} = recv(Config),
|
||||
#stream_features{sub_els = Fs} = recv(Config),
|
||||
if Type == client ->
|
||||
#xmpp_session{optional = true} =
|
||||
lists:keyfind(xmpp_session, 1, Fs);
|
||||
@ -417,39 +417,31 @@ match_failure(Received, [Match]) when is_list(Match)->
|
||||
match_failure(Received, Matches) ->
|
||||
ct:fail("Received input:~n~n~p~n~ndon't match expected patterns:~n~n~p", [Received, Matches]).
|
||||
|
||||
recv() ->
|
||||
recv(Config) ->
|
||||
receive
|
||||
{'$gen_event', {xmlstreamelement, El}} ->
|
||||
decode(El);
|
||||
NS = case ?config(type, Config) of
|
||||
client -> ?NS_CLIENT;
|
||||
server -> ?NS_SERVER;
|
||||
component -> ?NS_COMPONENT
|
||||
end,
|
||||
decode(El, NS, []);
|
||||
{'$gen_event', {xmlstreamstart, Name, Attrs}} ->
|
||||
decode(#xmlel{name = Name, attrs = Attrs});
|
||||
decode(#xmlel{name = Name, attrs = Attrs}, <<>>, []);
|
||||
{'$gen_event', Event} ->
|
||||
Event
|
||||
end.
|
||||
|
||||
decode(El) ->
|
||||
decode(El, NS, Opts) ->
|
||||
try
|
||||
Pkt = xmpp:decode(El),
|
||||
ct:pal("recv: ~p ->~n~s", [El, xmpp_codec:pp(Pkt)]),
|
||||
Pkt = xmpp:decode(El, NS, Opts),
|
||||
ct:pal("recv: ~p ->~n~s", [El, xmpp:pp(Pkt)]),
|
||||
Pkt
|
||||
catch _:{xmpp_codec, Why} ->
|
||||
ct:fail("recv failed: ~p->~n~s",
|
||||
[El, xmpp:format_error(Why)])
|
||||
end.
|
||||
|
||||
fix_ns(#xmlel{name = Tag, attrs = Attrs} = El)
|
||||
when Tag == <<"stream:features">>; Tag == <<"stream:error">> ->
|
||||
NewAttrs = [{<<"xmlns">>, <<"http://etherx.jabber.org/streams">>}
|
||||
|lists:keydelete(<<"xmlns">>, 1, Attrs)],
|
||||
El#xmlel{attrs = NewAttrs};
|
||||
fix_ns(#xmlel{name = Tag, attrs = Attrs} = El)
|
||||
when Tag == <<"message">>; Tag == <<"iq">>; Tag == <<"presence">> ->
|
||||
NewAttrs = [{<<"xmlns">>, <<"jabber:client">>}
|
||||
|lists:keydelete(<<"xmlns">>, 1, Attrs)],
|
||||
El#xmlel{attrs = NewAttrs};
|
||||
fix_ns(El) ->
|
||||
El.
|
||||
|
||||
send_text(Config, Text) ->
|
||||
ejabberd_socket:send(?config(socket, Config), Text).
|
||||
|
||||
@ -467,8 +459,8 @@ send(State, Pkt) ->
|
||||
_ ->
|
||||
{undefined, Pkt}
|
||||
end,
|
||||
El = xmpp_codec:encode(NewPkt),
|
||||
ct:pal("sent: ~p <-~n~s", [El, xmpp_codec:pp(NewPkt)]),
|
||||
El = xmpp:encode(NewPkt),
|
||||
ct:pal("sent: ~p <-~n~s", [El, xmpp:pp(NewPkt)]),
|
||||
Data = case NewPkt of
|
||||
#stream_start{} -> fxml:element_to_header(El);
|
||||
_ -> fxml:element_to_binary(El)
|
||||
@ -478,7 +470,7 @@ send(State, Pkt) ->
|
||||
|
||||
send_recv(State, IQ) ->
|
||||
ID = send(State, IQ),
|
||||
#iq{id = ID} = recv().
|
||||
#iq{id = ID} = recv(State).
|
||||
|
||||
sasl_new(<<"PLAIN">>, User, Server, Password) ->
|
||||
{<<User/binary, $@, Server/binary, 0, User/binary, 0, Password/binary>>,
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
-define(recv1(P1),
|
||||
P1 = (fun() ->
|
||||
V = recv(),
|
||||
V = recv(Config),
|
||||
case V of
|
||||
P1 -> V;
|
||||
_ -> suite:match_failure([V], [??P1])
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
-define(recv2(P1, P2),
|
||||
(fun() ->
|
||||
case {R1 = recv(), R2 = recv()} of
|
||||
case {R1 = recv(Config), R2 = recv(Config)} of
|
||||
{P1, P2} -> {R1, R2};
|
||||
{P2, P1} -> {R2, R1};
|
||||
{P1, V1} -> suite:match_failure([V1], [P2]);
|
||||
@ -35,7 +35,7 @@
|
||||
|
||||
-define(recv3(P1, P2, P3),
|
||||
(fun() ->
|
||||
case R3 = recv() of
|
||||
case R3 = recv(Config) of
|
||||
P1 -> insert(R3, 1, ?recv2(P2, P3));
|
||||
P2 -> insert(R3, 2, ?recv2(P1, P3));
|
||||
P3 -> insert(R3, 3, ?recv2(P1, P2));
|
||||
@ -45,7 +45,7 @@
|
||||
|
||||
-define(recv4(P1, P2, P3, P4),
|
||||
(fun() ->
|
||||
case R4 = recv() of
|
||||
case R4 = recv(Config) of
|
||||
P1 -> insert(R4, 1, ?recv3(P2, P3, P4));
|
||||
P2 -> insert(R4, 2, ?recv3(P1, P3, P4));
|
||||
P3 -> insert(R4, 3, ?recv3(P1, P2, P4));
|
||||
@ -56,7 +56,7 @@
|
||||
|
||||
-define(recv5(P1, P2, P3, P4, P5),
|
||||
(fun() ->
|
||||
case R5 = recv() of
|
||||
case R5 = recv(Config) of
|
||||
P1 -> insert(R5, 1, ?recv4(P2, P3, P4, P5));
|
||||
P2 -> insert(R5, 2, ?recv4(P1, P3, P4, P5));
|
||||
P3 -> insert(R5, 3, ?recv4(P1, P2, P4, P5));
|
||||
|
@ -316,7 +316,8 @@
|
||||
|
||||
-xml(iq,
|
||||
#elem{name = <<"iq">>,
|
||||
xmlns = <<"jabber:client">>,
|
||||
xmlns = [<<"jabber:client">>, <<"jabber:server">>,
|
||||
<<"jabber:component:accept">>],
|
||||
result = {iq, '$id', '$type', '$lang', '$from', '$to', '$_els'},
|
||||
attrs = [#attr{name = <<"id">>,
|
||||
required = true},
|
||||
@ -335,26 +336,30 @@
|
||||
|
||||
-xml(message_subject,
|
||||
#elem{name = <<"subject">>,
|
||||
xmlns = <<"jabber:client">>,
|
||||
xmlns = [<<"jabber:client">>, <<"jabber:server">>,
|
||||
<<"jabber:component:accept">>],
|
||||
result = {text, '$lang', '$data'},
|
||||
cdata = #cdata{label = '$data'},
|
||||
attrs = [#attr{name = <<"xml:lang">>, label = '$lang'}]}).
|
||||
|
||||
-xml(message_body,
|
||||
#elem{name = <<"body">>,
|
||||
xmlns = <<"jabber:client">>,
|
||||
xmlns = [<<"jabber:client">>, <<"jabber:server">>,
|
||||
<<"jabber:component:accept">>],
|
||||
result = {text, '$lang', '$data'},
|
||||
cdata = #cdata{label = '$data'},
|
||||
attrs = [#attr{name = <<"xml:lang">>, label = '$lang'}]}).
|
||||
|
||||
-xml(message_thread,
|
||||
#elem{name = <<"thread">>,
|
||||
xmlns = <<"jabber:client">>,
|
||||
xmlns = [<<"jabber:client">>, <<"jabber:server">>,
|
||||
<<"jabber:component:accept">>],
|
||||
result = '$cdata'}).
|
||||
|
||||
-xml(message,
|
||||
#elem{name = <<"message">>,
|
||||
xmlns = <<"jabber:client">>,
|
||||
xmlns = [<<"jabber:client">>, <<"jabber:server">>,
|
||||
<<"jabber:component:accept">>],
|
||||
result = {message, '$id', '$type', '$lang', '$from', '$to',
|
||||
'$subject', '$body', '$thread', '$_els'},
|
||||
attrs = [#attr{name = <<"id">>},
|
||||
@ -377,14 +382,16 @@
|
||||
|
||||
-xml(presence_show,
|
||||
#elem{name = <<"show">>,
|
||||
xmlns = <<"jabber:client">>,
|
||||
xmlns = [<<"jabber:client">>, <<"jabber:server">>,
|
||||
<<"jabber:component:accept">>],
|
||||
result = '$cdata',
|
||||
cdata = #cdata{enc = {enc_enum, []},
|
||||
dec = {dec_enum, [[away, chat, dnd, xa]]}}}).
|
||||
|
||||
-xml(presence_status,
|
||||
#elem{name = <<"status">>,
|
||||
xmlns = <<"jabber:client">>,
|
||||
xmlns = [<<"jabber:client">>, <<"jabber:server">>,
|
||||
<<"jabber:component:accept">>],
|
||||
result = {text, '$lang', '$data'},
|
||||
cdata = #cdata{label = '$data'},
|
||||
attrs = [#attr{name = <<"xml:lang">>,
|
||||
@ -392,14 +399,16 @@
|
||||
|
||||
-xml(presence_priority,
|
||||
#elem{name = <<"priority">>,
|
||||
xmlns = <<"jabber:client">>,
|
||||
xmlns = [<<"jabber:client">>, <<"jabber:server">>,
|
||||
<<"jabber:component:accept">>],
|
||||
result = '$cdata',
|
||||
cdata = #cdata{enc = {enc_int, []},
|
||||
dec = {dec_int, []}}}).
|
||||
|
||||
-xml(presence,
|
||||
#elem{name = <<"presence">>,
|
||||
xmlns = <<"jabber:client">>,
|
||||
xmlns = [<<"jabber:client">>, <<"jabber:server">>,
|
||||
<<"jabber:component:accept">>],
|
||||
result = {presence, '$id', '$type', '$lang', '$from', '$to',
|
||||
'$show', '$status', '$priority', '$_els'},
|
||||
attrs = [#attr{name = <<"id">>},
|
||||
@ -527,7 +536,8 @@
|
||||
|
||||
-xml(error,
|
||||
#elem{name = <<"error">>,
|
||||
xmlns = <<"jabber:client">>,
|
||||
xmlns = [<<"jabber:client">>, <<"jabber:server">>,
|
||||
<<"jabber:component:accept">>],
|
||||
result = {stanza_error, '$type', '$code', '$by', '$reason', '$text', '$_els'},
|
||||
attrs = [#attr{name = <<"type">>,
|
||||
label = '$type',
|
||||
@ -861,7 +871,7 @@
|
||||
|
||||
-xml(stream_features,
|
||||
#elem{name = <<"stream:features">>,
|
||||
xmlns = <<"http://etherx.jabber.org/streams">>,
|
||||
xmlns = [<<"jabber:client">>, <<"jabber:server">>],
|
||||
result = {stream_features, '$_els'}}).
|
||||
|
||||
-xml(p1_push,
|
||||
@ -1187,7 +1197,8 @@
|
||||
|
||||
-xml(stream_error,
|
||||
#elem{name = <<"stream:error">>,
|
||||
xmlns = <<"http://etherx.jabber.org/streams">>,
|
||||
xmlns = [<<"jabber:client">>, <<"jabber:server">>,
|
||||
<<"jabber:component:accept">>],
|
||||
result = {stream_error, '$reason', '$text'},
|
||||
refs = [#ref{name = stream_error_text,
|
||||
label = '$text',
|
||||
@ -3162,7 +3173,7 @@
|
||||
|
||||
-xml(db_result,
|
||||
#elem{name = <<"db:result">>,
|
||||
xmlns = <<"jabber:client">>,
|
||||
xmlns = <<"jabber:server">>,
|
||||
result = {db_result, '$from', '$to', '$type', '$key', '$_els'},
|
||||
cdata = #cdata{default = <<"">>, label = '$key'},
|
||||
attrs = [#attr{name = <<"from">>, required = true,
|
||||
@ -3175,7 +3186,7 @@
|
||||
|
||||
-xml(db_verify,
|
||||
#elem{name = <<"db:verify">>,
|
||||
xmlns = <<"jabber:client">>,
|
||||
xmlns = <<"jabber:server">>,
|
||||
result = {db_verify, '$from', '$to', '$id', '$type', '$key', '$_els'},
|
||||
cdata = #cdata{default = <<"">>, label = '$key'},
|
||||
attrs = [#attr{name = <<"from">>, required = true,
|
||||
@ -3189,7 +3200,7 @@
|
||||
|
||||
-xml(handshake,
|
||||
#elem{name = <<"handshake">>,
|
||||
xmlns = <<"jabber:client">>,
|
||||
xmlns = <<"jabber:component:accept">>,
|
||||
result = {handshake, '$data'},
|
||||
cdata = #cdata{default = <<"">>, label = '$data'}}).
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user