mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
Fix dialyzer warnings
This commit is contained in:
parent
017b2feac1
commit
b455d93c69
@ -165,58 +165,43 @@ handle_event({new_shaper, Shaper}, StateName, #state{ws = {_, WsPid}} = StateDat
|
|||||||
{next_state, StateName, StateData}.
|
{next_state, StateName, StateData}.
|
||||||
|
|
||||||
handle_sync_event({send_xml, Packet}, _From, StateName,
|
handle_sync_event({send_xml, Packet}, _From, StateName,
|
||||||
#state{ws = {_, WsPid}} = StateData) ->
|
#state{ws = {_, WsPid}} = StateData) ->
|
||||||
Packet2 = case Packet of
|
SN2 = case Packet of
|
||||||
{xmlstreamstart, _, Attrs} ->
|
{xmlstreamstart, _, Attrs} ->
|
||||||
Attrs2 = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>} |
|
Attrs2 = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>} |
|
||||||
lists:keydelete(<<"xmlns">>, 1, lists:keydelete(<<"xmlns:stream">>, 1, Attrs))],
|
lists:keydelete(<<"xmlns">>, 1, lists:keydelete(<<"xmlns:stream">>, 1, Attrs))],
|
||||||
{xmlstreamelement, #xmlel{name = <<"open">>, attrs = Attrs2}};
|
route_el(WsPid, #xmlel{name = <<"open">>, attrs = Attrs2}),
|
||||||
{xmlstreamend, _} ->
|
StateName;
|
||||||
{xmlstreamelement, #xmlel{name = <<"close">>,
|
{xmlstreamend, _} ->
|
||||||
attrs = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>}]}};
|
route_el(WsPid, #xmlel{name = <<"close">>,
|
||||||
{xmlstreamraw, <<"\r\n\r\n">>} -> % cdata ping
|
attrs = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>}]}),
|
||||||
skip;
|
stream_end_sent;
|
||||||
{xmlstreamelement, #xmlel{name=Name2} = El2} ->
|
{xmlstreamraw, <<"\r\n\r\n">>} ->
|
||||||
El3 = case Name2 of
|
% cdata ping
|
||||||
<<"stream:", _/binary>> ->
|
StateName;
|
||||||
fxml:replace_tag_attr(<<"xmlns:stream">>, ?NS_STREAM, El2);
|
{xmlstreamelement, #xmlel{name = Name2} = El2} ->
|
||||||
_ ->
|
El3 = case Name2 of
|
||||||
case fxml:get_tag_attr_s(<<"xmlns">>, El2) of
|
<<"stream:", _/binary>> ->
|
||||||
<<"">> ->
|
fxml:replace_tag_attr(<<"xmlns:stream">>, ?NS_STREAM, El2);
|
||||||
fxml:replace_tag_attr(<<"xmlns">>, <<"jabber:client">>, El2);
|
_ ->
|
||||||
_ ->
|
case fxml:get_tag_attr_s(<<"xmlns">>, El2) of
|
||||||
El2
|
<<"">> ->
|
||||||
end
|
fxml:replace_tag_attr(<<"xmlns">>, <<"jabber:client">>, El2);
|
||||||
end,
|
_ ->
|
||||||
{xmlstreamelement, El3}
|
El2
|
||||||
end,
|
end
|
||||||
case Packet2 of
|
end,
|
||||||
{xmlstreamstart, Name, Attrs3} ->
|
route_el(WsPid, El3),
|
||||||
B = fxml:element_to_binary(#xmlel{name = Name, attrs = Attrs3}),
|
StateName
|
||||||
route_text(WsPid, <<(binary:part(B, 0, byte_size(B)-2))/binary, ">">>);
|
end,
|
||||||
{xmlstreamend, Name} ->
|
|
||||||
route_text(WsPid, <<"</", Name/binary, ">">>);
|
|
||||||
{xmlstreamelement, El} ->
|
|
||||||
route_text(WsPid, fxml:element_to_binary(El));
|
|
||||||
{xmlstreamraw, Bin} ->
|
|
||||||
route_text(WsPid, Bin);
|
|
||||||
{xmlstreamcdata, Bin2} ->
|
|
||||||
route_text(WsPid, Bin2);
|
|
||||||
skip ->
|
|
||||||
ok
|
|
||||||
end,
|
|
||||||
SN2 = case Packet2 of
|
|
||||||
{xmlstreamelement, #xmlel{name = <<"close">>}} ->
|
|
||||||
stream_end_sent;
|
|
||||||
_ ->
|
|
||||||
StateName
|
|
||||||
end,
|
|
||||||
{reply, ok, SN2, StateData};
|
{reply, ok, SN2, StateData};
|
||||||
handle_sync_event(close, _From, StateName, #state{ws = {_, WsPid}} = StateData)
|
handle_sync_event(close, _From, StateName, #state{ws = {_, WsPid}} = StateData)
|
||||||
when StateName /= stream_end_sent ->
|
when StateName /= stream_end_sent ->
|
||||||
Close = #xmlel{name = <<"close">>,
|
Close = #xmlel{name = <<"close">>,
|
||||||
attrs = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>}]},
|
attrs = [{<<"xmlns">>, <<"urn:ietf:params:xml:ns:xmpp-framing">>}]},
|
||||||
route_text(WsPid, fxml:element_to_binary(Close)),
|
route_text(WsPid, fxml:element_to_binary(Close)),
|
||||||
|
{stop, normal, StateData};
|
||||||
|
handle_sync_event(close, _From, _StateName, StateData) ->
|
||||||
{stop, normal, StateData}.
|
{stop, normal, StateData}.
|
||||||
|
|
||||||
handle_info(closed, _StateName, StateData) ->
|
handle_info(closed, _StateName, StateData) ->
|
||||||
@ -225,7 +210,7 @@ handle_info({received, Packet}, StateName, StateDataI) ->
|
|||||||
{StateData, Parsed} = parse(StateDataI, Packet),
|
{StateData, Parsed} = parse(StateDataI, Packet),
|
||||||
SD = case StateData#state.active of
|
SD = case StateData#state.active of
|
||||||
false ->
|
false ->
|
||||||
Input = StateData#state.input ++ if is_binary(Parsed) -> [Parsed]; true -> Parsed end,
|
Input = StateData#state.input ++ Parsed,
|
||||||
StateData#state{input = Input};
|
StateData#state{input = Input};
|
||||||
true ->
|
true ->
|
||||||
StateData#state.c2s_pid ! {tcp, StateData#state.socket, Parsed},
|
StateData#state.c2s_pid ! {tcp, StateData#state.socket, Parsed},
|
||||||
@ -330,3 +315,7 @@ route_text(Pid, Data) ->
|
|||||||
{text_reply, Pid} ->
|
{text_reply, Pid} ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec route_el(pid(), xmlel() | cdata()) -> ok.
|
||||||
|
route_el(Pid, Data) ->
|
||||||
|
route_text(Pid, fxml:element_to_binary(Data)).
|
||||||
|
Loading…
Reference in New Issue
Block a user