From b11b8caf9da0247e1aa8db47901a7bf30f45c2b8 Mon Sep 17 00:00:00 2001 From: Alexey Shchepin Date: Wed, 10 Mar 2004 21:54:54 +0000 Subject: [PATCH] * src/web/ejabberd_http.erl: Removed debugging output * src/ejabberd_c2s.erl: Fixed processing of get_presence request (thanks to Mickael Remond) SVN Revision: 212 --- ChangeLog | 7 +++++++ src/ejabberd_c2s.erl | 34 +++++++++++++++++++++------------- src/web/ejabberd_http.erl | 11 ++++++----- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index d5d10c312..d118bc9d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-03-10 Alexey Shchepin + + * src/web/ejabberd_http.erl: Removed debugging output + + * src/ejabberd_c2s.erl: Fixed processing of get_presence request + (thanks to Mickael Remond) + 2004-03-08 Alexey Shchepin * src/msgs/ru.msg: Updated (thanks to Sergei Golovan) diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index b2bd9924f..a85ee24e0 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -668,24 +668,19 @@ handle_event(_Event, StateName, StateData) -> %%---------------------------------------------------------------------- handle_sync_event({get_presence}, _From, StateName, StateData) -> User = StateData#state.user, - Status = - case StateData#state.pres_last of - undefined -> - "unavailable"; - PresLast -> - case xml:get_path_s(PresLast, [{elem, "status"}, cdata]) of - "" -> - "available"; - Stat -> - Stat - end - end, - Reply = {User, Status}, + PresLast = StateData#state.pres_last, + + Show = get_showtag(PresLast), + Status = get_statustag(PresLast), + + Reply = {User, Show, Status}, {reply, Reply, StateName, StateData}; + handle_sync_event(_Event, _From, StateName, StateData) -> Reply = ok, {reply, Reply, StateName, StateData}. + code_change(_OldVsn, StateName, StateData, _Extra) -> {ok, StateName, StateData}. @@ -1322,4 +1317,17 @@ resend_offline_messages(StateData) -> end, Rs) end. +get_showtag(undefined) -> + "unavailable"; +get_showtag(Presence) -> + case xml:get_path_s(Presence, [{elem, "show"}, cdata]) of + "" -> "available"; + ShowTag -> ShowTag + end. +get_statustag(undefined) -> + ""; +get_statustag(Presence) -> + case xml:get_path_s(Presence, [{elem, "status"}, cdata]) of + ShowTag -> ShowTag + end. diff --git a/src/web/ejabberd_http.erl b/src/web/ejabberd_http.erl index 8c1b99676..bb90766f2 100644 --- a/src/web/ejabberd_http.erl +++ b/src/web/ejabberd_http.erl @@ -55,7 +55,7 @@ send_text(State, Text) -> receive_headers(State) -> Data = (State#state.sockmod):recv(State#state.socket, 0, 300000), - ?INFO_MSG("recv: ~p~n", [Data]), + ?DEBUG("recv: ~p~n", [Data]), case Data of {ok, {http_request, Method, Path, _Version}} -> receive_headers(State#state{request_method = Method, @@ -72,6 +72,10 @@ receive_headers(State) -> {ok, {http_header, _, _, _, _}} -> receive_headers(State); {ok, http_eoh} -> + ?INFO_MSG("(~w) http query: ~w ~s~n", + [State#state.socket, + State#state.request_method, + element(2, State#state.request_path)]), Out = process_request(State), send_text(State, Out), ok; @@ -110,7 +114,6 @@ process_request(#state{request_method = 'GET', process_request(false); {NPath, Query} -> LQuery = parse_urlencoded(Query), - ?INFO_MSG("path: ~p, query: ~p~n", [NPath, LQuery]), LPath = string:tokens(NPath, "/"), Request = #request{method = 'GET', path = LPath, @@ -162,15 +165,13 @@ process_request(#state{request_method = 'POST', ssl:setopts(Socket, [{packet, 0}]) end, Data = recv_data(State, Len), - ?INFO_MSG("client data: ~p~n", [Data]), + ?DEBUG("client data: ~p~n", [Data]), case (catch url_decode_q_split(Path)) of {'EXIT', _} -> process_request(false); {NPath, Query} -> - ?INFO_MSG("path: ~p, query: ~p~n", [NPath, Query]), LPath = string:tokens(NPath, "/"), LQuery = parse_urlencoded(Data), - ?INFO_MSG("client query: ~p~n", [LQuery]), Request = #request{method = 'POST', path = LPath, q = LQuery,