mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
Remove very old useless comments in ejabberd_xmlrpc.erl
This commit is contained in:
parent
7079634f18
commit
5ecbed5eae
@ -23,9 +23,6 @@
|
||||
%%%
|
||||
%%%----------------------------------------------------------------------
|
||||
|
||||
%%% TODO: Implement a command in ejabberdctl 'help COMMAND LANGUAGE' that shows
|
||||
%%% a coding example to call that command in a specific language (python, php).
|
||||
|
||||
%%% TODO: Remove support for plaintext password
|
||||
|
||||
%%% TODO: commands strings should be strings without ~n
|
||||
@ -50,140 +47,6 @@
|
||||
get_auth = true :: boolean(),
|
||||
ip :: inet:ip_address()}).
|
||||
|
||||
%% Test:
|
||||
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, take_integer, [{struct, [{thisinteger, 5}]}]}).
|
||||
%% {ok,{response,[{struct,[{zero,0}]}]}}
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, echo_string, [{struct, [{thisstring, "abcd"}]}]}).
|
||||
%% {ok,{response,[{struct,[{thatstring,"abcd"}]}]}}
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, tell_tuple_3integer, [{struct, [{thisstring, "abcd"}]}]}).
|
||||
%% {ok,{response,
|
||||
%% [{struct,
|
||||
%% [{thattuple,
|
||||
%% {array,
|
||||
%% [{struct,[{first,123}]},
|
||||
%% {struct,[{second,456}]},
|
||||
%% {struct,[{third,789}]}]}}]}]}}
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, pow, [{struct, [{base, 5}, {exponent, 7}]}]}).
|
||||
%% {ok,{response,[{struct,[{pow,78125}]}]}}
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, seq, [{struct, [{from, 3}, {to, 7}]}]}).
|
||||
%% {ok,{response,[{array,[{struct,[{intermediate,3}]},
|
||||
%% {struct,[{intermediate,4}]},
|
||||
%% {struct,[{intermediate,5}]},
|
||||
%% {struct,[{intermediate,6}]},
|
||||
%% {struct,[{intermediate,7}]}]}]}}
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, substrs, [{struct, [{word, "abcd"}]}]}).
|
||||
%% NO:
|
||||
%% {ok,{response,[{array,[{struct,[{miniword,"a"}]},
|
||||
%% {struct,[{miniword,"ab"}]},
|
||||
%% {struct,[{miniword,"abc"}]},
|
||||
%% {struct,[{miniword,"abcd"}]}]}]}}
|
||||
%% {ok,{response,
|
||||
%% [{struct,
|
||||
%% [{substrings,
|
||||
%% {array,
|
||||
%% [{struct,[{miniword,"a"}]},
|
||||
%% {struct,[{miniword,"ab"}]},
|
||||
%% {struct,[{miniword,"abc"}]},
|
||||
%% {struct,[{miniword,"abcd"}]}]}}]}]}}
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, splitjid, [{struct, [{jid, "abcd@localhost/work"}]}]}).
|
||||
%% {ok,{response,
|
||||
%% [{struct,
|
||||
%% [{jidparts,
|
||||
%% {array,
|
||||
%% [{struct,[{user,"abcd"}]},
|
||||
%% {struct,[{server,"localhost"}]},
|
||||
%% {struct,[{resource,"work"}]}]}}]}]}}
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, echo_integer_string, [{struct, [{thisstring, "abc"}, {thisinteger, 55}]}]}).
|
||||
%% {ok,{response,
|
||||
%% [{struct,
|
||||
%% [{thistuple,
|
||||
%% {array,
|
||||
%% [{struct,[{thisinteger,55}]},
|
||||
%% {struct,[{thisstring,"abc"}]}]}}]}]}}
|
||||
%%
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, echo_list_integer, [{struct, [{thislist, {array, [{struct, [{thisinteger, 55}, {thisinteger, 4567}]}]}}]}]}).
|
||||
%% {ok,{response,
|
||||
%% [{struct,
|
||||
%% [{thatlist,
|
||||
%% {array,
|
||||
%% [{struct,[{thatinteger,55}]},
|
||||
%% {struct,[{thatinteger,4567}]}]}}]}]}}
|
||||
%%
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, echo_integer_list_string, [{struct, [{thisinteger, 123456}, {thislist, {array, [{struct, [{thisstring, "abc"}, {thisstring, "bobo baba"}]}]}}]}]}).
|
||||
%% {ok,
|
||||
%% {response,
|
||||
%% [{struct,
|
||||
%% [{thistuple,
|
||||
%% {array,
|
||||
%% [{struct,[{thatinteger,123456}]},
|
||||
%% {struct,
|
||||
%% [{thatlist,
|
||||
%% {array,
|
||||
%% [{struct,[{thatstring,"abc"}]},
|
||||
%% {struct,[{thatstring,"bobo baba"}]}]}}]}]}}]}]}}
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, take_tuple_2integer, [{struct, [{thistuple, {array, [{struct, [{thisinteger1, 55}, {thisinteger2, 4567}]}]}}]}]}).
|
||||
%% {ok,{response,[{struct,[{zero,0}]}]}}
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, echo_isatils, [{struct,
|
||||
%% [{thisinteger, 123456990},
|
||||
%% {thisstring, "This is ISATILS"},
|
||||
%% {thisatom, "test_isatils"},
|
||||
%% {thistuple, {array, [{struct, [
|
||||
%% {listlen, 2},
|
||||
%% {thislist, {array, [{struct, [
|
||||
%% {contentstring, "word1"},
|
||||
%% {contentstring, "word 2"}
|
||||
%% ]}]}}
|
||||
%% ]}]}}
|
||||
%% ]}]}).
|
||||
%% {ok,{response,
|
||||
%% [{struct,
|
||||
%% [{results,
|
||||
%% {array,
|
||||
%% [{struct,[{thatinteger,123456990}]},
|
||||
%% {struct,[{thatstring,"This is ISATILS"}]},
|
||||
%% {struct,[{thatatom,"test_isatils"}]},
|
||||
%% {struct,
|
||||
%% [{thattuple,
|
||||
%% {array,
|
||||
%% [{struct,[{listlen,123456990}]},
|
||||
%% {struct,[{thatlist,...}]}]}}]}]}}]}]}}
|
||||
|
||||
%% ecommand doesn't exist:
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, echo_integer_string2, [{struct, [{thisstring, "abc"}]}]}).
|
||||
%% {ok,{response,{fault,-1, "Unknown call: {call,echo_integer_string2,[{struct,[{thisstring,\"abc\"}]}]}"}}}
|
||||
%%
|
||||
%% Duplicated argument:
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, echo_integer_string, [{struct, [{thisstring, "abc"}, {thisinteger, 44}, {thisinteger, 55}]}]}).
|
||||
%% {ok,{response,{fault,-104, "Error -104\nAttribute 'thisinteger' duplicated:\n[{thisstring,\"abc\"},{thisinteger,44},{thisinteger,55}]"}}}
|
||||
%%
|
||||
%% Missing argument:
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, echo_integer_string, [{struct, [{thisstring, "abc"}]}]}).
|
||||
%% {ok,{response,{fault,-106, "Error -106\nRequired attribute 'thisinteger' not found:\n[{thisstring,\"abc\"}]"}}}
|
||||
%%
|
||||
%% Duplicated tuple element:
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, take_tuple_2integer, [{struct, [{thistuple, {array, [{struct, [{thisinteger1, 55}, {thisinteger1, 66}, {thisinteger2, 4567}]}]}}]}]}).
|
||||
%% {ok,{response,{fault,-104, "Error -104\nAttribute 'thisinteger1' defined multiple times:\n[{thisinteger1,55},{thisinteger1,66},{thisinteger2,4567}]"}}}
|
||||
%%
|
||||
%% Missing element in tuple:
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, take_tuple_2integer, [{struct, [{thistuple, {array, [{struct, [{thisinteger1, 55}, {thisintegerc, 66}, {thisinteger, 4567}]}]}}]}]}).
|
||||
%% {ok,{response,{fault,-106, "Error -106\nRequired attribute 'thisinteger2' not found:\n[{thisintegerc,66},{thisinteger,4567}]"}}}
|
||||
%%
|
||||
%% The ecommand crashed:
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, this_crashes, [{struct, []}]}).
|
||||
%% {ok,{response,{fault,-100, "Error -100\nA problem 'error' occurred executing the command this_crashes with arguments []: badarith"}}}
|
||||
|
||||
%% -----------------------------
|
||||
%% Listener interface
|
||||
%% -----------------------------
|
||||
@ -202,6 +65,7 @@ accept(Pid) ->
|
||||
%% -----------------------------
|
||||
%% HTTP interface
|
||||
%% -----------------------------
|
||||
|
||||
process(_, #request{method = 'POST', data = Data, opts = Opts, ip = {IP, _}}) ->
|
||||
AccessCommands = proplists:get_value(access_commands, Opts, []),
|
||||
GetAuth = true,
|
||||
@ -235,6 +99,7 @@ process(_, _) ->
|
||||
%% -----------------------------
|
||||
%% Access verification
|
||||
%% -----------------------------
|
||||
|
||||
-spec extract_auth([{user | server | token | password, binary()}]) ->
|
||||
map() | {error, not_found | expired | invalid_auth}.
|
||||
extract_auth(AuthList) ->
|
||||
@ -273,26 +138,6 @@ extract_auth(AuthList) ->
|
||||
%% Handlers
|
||||
%% -----------------------------
|
||||
|
||||
%% Call: Arguments: Returns:
|
||||
|
||||
%% .............................
|
||||
%% Access verification
|
||||
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, echothis, [152]}).
|
||||
%% {ok,{response,{fault,-103, "Error -103\nRequired authentication: {call,echothis,[152]}"}}}
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, echothis, [{struct, [{user, "badlop"}, {server, "localhost"}, {password, "ada"}]}, 152]}).
|
||||
%% {ok,{response,{fault,-103,
|
||||
%% "Error -103\nAuthentication non valid: [{user,\"badlop\"},\n
|
||||
%% {server,\"localhost\"},\n
|
||||
%% {password,\"ada\"}]"}}}
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, echothis, [{struct, [{user, "badlop"}, {server, "localhost"}, {password, "ada90ada"}]}, 152]}).
|
||||
%% {ok,{response,[152]}}
|
||||
%%
|
||||
%% xmlrpc:call({127, 0, 0, 1}, 4560, "/", {call, echothis, [{struct, [{user, "badlop"}, {server, "localhost"}, {password, "79C1574A43BC995F2B145A299EF97277"}]}, 152]}).
|
||||
%% {ok,{response,[152]}}
|
||||
|
||||
handler(#state{get_auth = true, auth = noauth, ip = IP} = State,
|
||||
{call, Method,
|
||||
[{struct, AuthList} | Arguments] = AllArgs}) ->
|
||||
@ -318,25 +163,28 @@ handler(#state{get_auth = true, auth = noauth, ip = IP} = State,
|
||||
auth = #{ip => IP, caller_module => ?MODULE}},
|
||||
{call, Method, AllArgs})
|
||||
end;
|
||||
|
||||
%% .............................
|
||||
%% Debug
|
||||
%% echothis String String
|
||||
|
||||
handler(_State, {call, echothis, [A]}) ->
|
||||
{false, {response, [A]}};
|
||||
%% echothisnew struct[{sentence, String}] struct[{repeated, String}]
|
||||
|
||||
handler(_State,
|
||||
{call, echothisnew, [{struct, [{sentence, A}]}]}) ->
|
||||
{false, {response, [{struct, [{repeated, A}]}]}};
|
||||
%% multhis struct[{a, Integer}, {b, Integer}] Integer
|
||||
|
||||
handler(_State,
|
||||
{call, multhis, [{struct, [{a, A}, {b, B}]}]}) ->
|
||||
{false, {response, [A * B]}};
|
||||
%% multhisnew struct[{a, Integer}, {b, Integer}] struct[{mu, Integer}]
|
||||
|
||||
handler(_State,
|
||||
{call, multhisnew, [{struct, [{a, A}, {b, B}]}]}) ->
|
||||
{false, {response, [{struct, [{mu, A * B}]}]}};
|
||||
|
||||
%% .............................
|
||||
%% ejabberd commands
|
||||
|
||||
handler(State, {call, Command, []}) ->
|
||||
handler(State, {call, Command, [{struct, []}]});
|
||||
handler(State,
|
||||
@ -344,7 +192,6 @@ handler(State,
|
||||
{ArgsF, ArgsR, ResultF} = ejabberd_commands:get_command_format(Command, State#state.auth),
|
||||
try_do_command(State#state.access_commands,
|
||||
State#state.auth, Command, AttrL, ArgsF, ArgsR, ResultF);
|
||||
%% If no other guard matches
|
||||
handler(_State, Payload) ->
|
||||
build_fault_response(-112, "Unknown call: ~p",
|
||||
[Payload]).
|
||||
@ -421,7 +268,6 @@ get_attr(A, L) ->
|
||||
case lists:keysearch(A, 1, L) of
|
||||
{value, {A, Value}} -> Value;
|
||||
false ->
|
||||
%% Report the error and then force a crash
|
||||
exit({attribute_not_found, A, L})
|
||||
end.
|
||||
|
||||
@ -429,10 +275,8 @@ get_elem_delete(A, L) ->
|
||||
case proplists:get_all_values(A, L) of
|
||||
[Value] -> {Value, proplists:delete(A, L)};
|
||||
[_, _ | _] ->
|
||||
%% Crash reporting the error
|
||||
exit({duplicated_attribute, A, L});
|
||||
[] ->
|
||||
%% Report the error and then force a crash
|
||||
exit({attribute_not_found, A, L})
|
||||
end.
|
||||
|
||||
@ -528,14 +372,12 @@ format_result({Code, Text}, {Name, restuple}) ->
|
||||
{struct,
|
||||
[{Name, make_status(Code)},
|
||||
{text, lists:flatten(Text)}]};
|
||||
%% Result is a list of something: [something()]
|
||||
format_result(Elements, {Name, {list, ElementsDef}}) ->
|
||||
FormattedList = lists:map(fun (Element) ->
|
||||
format_result(Element, ElementsDef)
|
||||
end,
|
||||
Elements),
|
||||
{struct, [{Name, {array, FormattedList}}]};
|
||||
%% Result is a tuple with several elements: {something1(), something2(), ...}
|
||||
format_result(ElementsTuple,
|
||||
{Name, {tuple, ElementsDef}}) ->
|
||||
ElementsList = tuple_to_list(ElementsTuple),
|
||||
|
Loading…
Reference in New Issue
Block a user