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