25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

Several fixes about binary in mod_muc_room

This commit is contained in:
Badlop 2010-06-21 23:32:01 +02:00
parent 98a78b7955
commit a610d8b699

View File

@ -764,9 +764,9 @@ terminate(Reason, _StateName, StateData) ->
?INFO_MSG("Stopping MUC room ~s@~s", ?INFO_MSG("Stopping MUC room ~s@~s",
[StateData#state.room, StateData#state.host]), [StateData#state.room, StateData#state.host]),
ReasonT = case Reason of ReasonT = case Reason of
shutdown -> "You are being removed from the room because" shutdown -> <<"You are being removed from the room because"
" of a system shutdown"; " of a system shutdown">>;
_ -> "Room terminates" _ -> <<"Room terminates">>
end, end,
ReasonEl = #xmlel{name = 'reason', children = [#xmlcdata{cdata = ReasonT}]}, ReasonEl = #xmlel{name = 'reason', children = [#xmlcdata{cdata = ReasonT}]},
ItemAttrs = [?XMLATTR('affiliation', <<"none">>), ItemAttrs = [?XMLATTR('affiliation', <<"none">>),
@ -2959,8 +2959,8 @@ is_password_settings_correct(XEl, StateData) ->
-define(BOOLXFIELD(Label, Var, Val), -define(BOOLXFIELD(Label, Var, Val),
?XFIELD("boolean", Label, Var, ?XFIELD("boolean", Label, Var,
case Val of case Val of
true -> "1"; true -> <<"1">>;
_ -> "0" _ -> <<"0">>
end)). end)).
-define(STRINGXFIELD(Label, Var, Val), -define(STRINGXFIELD(Label, Var, Val),
@ -2988,8 +2988,8 @@ get_config(Lang, StateData, From) ->
end, end,
Res = Res =
[#xmlel{name = 'title', children = [ #xmlcdata{cdata = [#xmlel{name = 'title', children = [ #xmlcdata{cdata =
io_lib:format(translate:translate(Lang, "Configuration of room ~s"), list_to_binary(io_lib:format(translate:translate(Lang, "Configuration of room ~s"),
[exmpp_jid:to_list(StateData#state.jid)]) [exmpp_jid:to_list(StateData#state.jid)]))
}]}, }]},
#xmlel{name = 'field', attrs = [?XMLATTR('type', <<"hidden">>), #xmlel{name = 'field', attrs = [?XMLATTR('type', <<"hidden">>),
?XMLATTR('var', <<"FORM_TYPE">>)], ?XMLATTR('var', <<"FORM_TYPE">>)],
@ -3033,7 +3033,7 @@ get_config(Lang, StateData, From) ->
?XMLATTR('var', <<"muc#roomconfig_maxusers">>)], ?XMLATTR('var', <<"muc#roomconfig_maxusers">>)],
children = [#xmlel{name = 'value', children = [#xmlel{name = 'value',
children = [#xmlcdata{cdata = children = [#xmlcdata{cdata =
MaxUsersRoomString}]}] ++ list_to_binary(MaxUsersRoomString)}]}] ++
if if
is_integer(ServiceMaxUsers) -> []; is_integer(ServiceMaxUsers) -> [];
true -> true ->
@ -3044,7 +3044,7 @@ get_config(Lang, StateData, From) ->
end ++ end ++
[#xmlel{name = 'option', attrs = [?XMLATTR('label', N)], [#xmlel{name = 'option', attrs = [?XMLATTR('label', N)],
children = [#xmlel{name = 'value', children = [ children = [#xmlel{name = 'value', children = [
#xmlcdata{cdata = erlang:integer_to_list(N)}]}]} || #xmlcdata{cdata = list_to_binary(erlang:integer_to_list(N))}]}]} ||
N <- lists:usort([ServiceMaxUsers, DefaultRoomMaxUsers, MaxUsersRoomInteger | N <- lists:usort([ServiceMaxUsers, DefaultRoomMaxUsers, MaxUsersRoomInteger |
?MAX_USERS_DEFAULT_LIST]), N =< ServiceMaxUsers]}, ?MAX_USERS_DEFAULT_LIST]), N =< ServiceMaxUsers]},
#xmlel{name = 'field', attrs = [ #xmlel{name = 'field', attrs = [
@ -3425,14 +3425,14 @@ process_iq_disco_info(_From, get, Lang, StateData) ->
#xmlel{name = 'field', attrs = [?XMLATTR('type', Type), #xmlel{name = 'field', attrs = [?XMLATTR('type', Type),
?XMLATTR('var', Var)], ?XMLATTR('var', Var)],
children = [#xmlel{name = 'value', children = [#xmlel{name = 'value',
children = [#xmlcdata{cdata = Val}]}]}). children = [#xmlcdata{cdata = list_to_binary(Val)}]}]}).
-define(RFIELD(Label, Var, Val), -define(RFIELD(Label, Var, Val),
#xmlel{name = 'field', attrs = [?XMLATTR('label', #xmlel{name = 'field', attrs = [?XMLATTR('label',
translate:translate(Lang, Label)), translate:translate(Lang, Label)),
?XMLATTR('var', Var)], ?XMLATTR('var', Var)],
children = [#xmlel{name = 'value', children = [ children = [#xmlel{name = 'value', children = [
#xmlcdata{cdata = Val}]}]}). #xmlcdata{cdata = list_to_binary(Val)}]}]}).
iq_disco_info_extras(Lang, StateData) -> iq_disco_info_extras(Lang, StateData) ->
Len = length(?DICT:to_list(StateData#state.users)), Len = length(?DICT:to_list(StateData#state.users)),