25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

New command get_room_options (#567)

This commit is contained in:
Badlop 2015-05-15 17:47:10 +02:00
parent 61afd668c2
commit 084d0c4efe
3 changed files with 42 additions and 0 deletions

View File

@ -353,6 +353,15 @@ format_result(String, {_Name, string}) when is_list(String) ->
format_result(Binary, {_Name, string}) when is_binary(Binary) ->
io_lib:format("~s", [binary_to_list(Binary)]);
format_result(Atom, {_Name, string}) when is_atom(Atom) ->
io_lib:format("~s", [atom_to_list(Atom)]);
format_result(Integer, {_Name, string}) when is_integer(Integer) ->
io_lib:format("~s", [integer_to_list(Integer)]);
format_result(Other, {_Name, string}) ->
io_lib:format("~p", [Other]);
format_result(Code, {_Name, rescode}) ->
make_status(Code);

View File

@ -466,6 +466,12 @@ format_result(String, {Name, string}) when is_list(String) ->
{struct, [{Name, lists:flatten(String)}]};
format_result(Binary, {Name, string}) when is_binary(Binary) ->
{struct, [{Name, binary_to_list(Binary)}]};
format_result(Atom, {Name, string}) when is_atom(Atom) ->
{struct, [{Name, atom_to_list(Atom)}]};
format_result(Integer, {Name, string}) when is_integer(Integer) ->
{struct, [{Name, integer_to_list(Integer)}]};
format_result(Other, {Name, string}) ->
{struct, [{Name, io_lib:format("~p", [Other])}]};
format_result(String, {Name, binary}) when is_list(String) ->
{struct, [{Name, lists:flatten(String)}]};
format_result(Binary, {Name, binary}) when is_binary(Binary) ->

View File

@ -23,6 +23,7 @@
get_room_occupants_number/2,
send_direct_invitation/4,
change_room_option/4,
get_room_options/2,
set_room_affiliation/4,
get_room_affiliations/2,
web_menu_main/2, web_page_main/2, % Web Admin API
@ -145,6 +146,16 @@ commands() ->
args = [{name, binary}, {service, binary},
{option, binary}, {value, binary}],
result = {res, rescode}},
#ejabberd_commands{name = get_room_options, tags = [muc_room],
desc = "Get options from a MUC room",
module = ?MODULE, function = get_room_options,
args = [{name, binary}, {service, binary}],
result = {options, {list,
{option, {tuple,
[{name, string},
{value, string}
]}}
}}},
#ejabberd_commands{name = set_room_affiliation, tags = [muc_room],
desc = "Change an affiliation in a MUC room",
@ -799,6 +810,22 @@ change_option(Option, Value, Config) ->
title -> Config#config{title = Value}
end.
%%----------------------------
%% Get Room Options
%%----------------------------
get_room_options(Name, Service) ->
Pid = get_room_pid(Name, Service),
get_room_options(Pid).
get_room_options(Pid) ->
Config = get_room_config(Pid),
get_options(Config).
get_options(Config) ->
Fields = record_info(fields, config),
[config | Values] = tuple_to_list(Config),
lists:zip(Fields, Values).
%%----------------------------
%% Get Room Affiliations