Get rid of excessive (io)list_to_binary/1 calls
This commit is contained in:
parent
b14843d098
commit
49f1275e20
|
@ -342,7 +342,7 @@ acl_rule_verify({node_glob, {UR, SR}}) when is_binary(UR), is_binary(SR) ->
|
||||||
acl_rule_verify(_Spec) ->
|
acl_rule_verify(_Spec) ->
|
||||||
false.
|
false.
|
||||||
invalid_syntax(Msg, Data) ->
|
invalid_syntax(Msg, Data) ->
|
||||||
throw({invalid_syntax, iolist_to_binary(io_lib:format(Msg, Data))}).
|
throw({invalid_syntax, (str:format(Msg, Data))}).
|
||||||
|
|
||||||
acl_rules_verify([{acl, Name} | Rest], true) when is_atom(Name) ->
|
acl_rules_verify([{acl, Name} | Rest], true) when is_atom(Name) ->
|
||||||
acl_rules_verify(Rest, true);
|
acl_rules_verify(Rest, true);
|
||||||
|
|
|
@ -532,10 +532,10 @@ key_split([{Arg, Value} | Rest], Results, Order, Required, Duplicates) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
report_error(Format, Args) ->
|
report_error(Format, Args) ->
|
||||||
throw({invalid_syntax, iolist_to_binary(io_lib:format(Format, Args))}).
|
throw({invalid_syntax, (str:format(Format, Args))}).
|
||||||
|
|
||||||
parse_error(Format, Args) ->
|
parse_error(Format, Args) ->
|
||||||
{error, iolist_to_binary(io_lib:format(Format, Args))}.
|
{error, (str:format(Format, Args))}.
|
||||||
|
|
||||||
opt_type(api_permissions) ->
|
opt_type(api_permissions) ->
|
||||||
fun parse_api_permissions/1;
|
fun parse_api_permissions/1;
|
||||||
|
|
|
@ -302,8 +302,8 @@ set_loglevel(LogLevel) ->
|
||||||
%%%
|
%%%
|
||||||
|
|
||||||
stop_kindly(DelaySeconds, AnnouncementTextString) ->
|
stop_kindly(DelaySeconds, AnnouncementTextString) ->
|
||||||
Subject = list_to_binary(io_lib:format("Server stop in ~p seconds!", [DelaySeconds])),
|
Subject = (str:format("Server stop in ~p seconds!", [DelaySeconds])),
|
||||||
WaitingDesc = list_to_binary(io_lib:format("Waiting ~p seconds", [DelaySeconds])),
|
WaitingDesc = (str:format("Waiting ~p seconds", [DelaySeconds])),
|
||||||
AnnouncementText = list_to_binary(AnnouncementTextString),
|
AnnouncementText = list_to_binary(AnnouncementTextString),
|
||||||
Steps = [
|
Steps = [
|
||||||
{"Stopping ejabberd port listeners",
|
{"Stopping ejabberd port listeners",
|
||||||
|
@ -337,8 +337,7 @@ stop_kindly(DelaySeconds, AnnouncementTextString) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
send_service_message_all_mucs(Subject, AnnouncementText) ->
|
send_service_message_all_mucs(Subject, AnnouncementText) ->
|
||||||
Message = list_to_binary(
|
Message = str:format("~s~n~s", [Subject, AnnouncementText]),
|
||||||
io_lib:format("~s~n~s", [Subject, AnnouncementText])),
|
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(ServerHost) ->
|
fun(ServerHost) ->
|
||||||
MUCHost = gen_mod:get_module_opt_host(
|
MUCHost = gen_mod:get_module_opt_host(
|
||||||
|
|
|
@ -807,7 +807,7 @@ encode_body(#body{attrs = Attrs, els = Els}, Type) ->
|
||||||
true -> {AmK, <<"true">>};
|
true -> {AmK, <<"true">>};
|
||||||
false -> {AmK, <<"false">>};
|
false -> {AmK, <<"false">>};
|
||||||
I when is_integer(I), I >= 0 ->
|
I when is_integer(I), I >= 0 ->
|
||||||
{AmK, iolist_to_binary(integer_to_list(I))};
|
{AmK, integer_to_binary(I)};
|
||||||
_ -> {AmK, V}
|
_ -> {AmK, V}
|
||||||
end;
|
end;
|
||||||
({K, V}) -> {K, V}
|
({K, V}) -> {K, V}
|
||||||
|
|
|
@ -103,7 +103,7 @@ create_captcha(SID, From, To, Lang, Limiter, Args) ->
|
||||||
BodyString1 = translate:translate(Lang,
|
BodyString1 = translate:translate(Lang,
|
||||||
<<"Your messages to ~s are being blocked. "
|
<<"Your messages to ~s are being blocked. "
|
||||||
"To unblock them, visit ~s">>),
|
"To unblock them, visit ~s">>),
|
||||||
BodyString = iolist_to_binary(io_lib:format(BodyString1,
|
BodyString = (str:format(BodyString1,
|
||||||
[JID, get_url(Id)])),
|
[JID, get_url(Id)])),
|
||||||
Body = xmpp:mk_text(BodyString, Lang),
|
Body = xmpp:mk_text(BodyString, Lang),
|
||||||
OOB = #oob_x{url = get_url(Id)},
|
OOB = #oob_x{url = get_url(Id)},
|
||||||
|
|
|
@ -550,12 +550,12 @@ make_xhtml_output(State, Status, Headers, XHTML) ->
|
||||||
of
|
of
|
||||||
{value, _} ->
|
{value, _} ->
|
||||||
[{<<"Content-Length">>,
|
[{<<"Content-Length">>,
|
||||||
iolist_to_binary(integer_to_list(byte_size(Data)))}
|
integer_to_binary(byte_size(Data))}
|
||||||
| Headers];
|
| Headers];
|
||||||
_ ->
|
_ ->
|
||||||
[{<<"Content-Type">>, <<"text/html; charset=utf-8">>},
|
[{<<"Content-Type">>, <<"text/html; charset=utf-8">>},
|
||||||
{<<"Content-Length">>,
|
{<<"Content-Length">>,
|
||||||
iolist_to_binary(integer_to_list(byte_size(Data)))}
|
integer_to_binary(byte_size(Data))}
|
||||||
| Headers]
|
| Headers]
|
||||||
end,
|
end,
|
||||||
HeadersOut = case {State#state.request_version,
|
HeadersOut = case {State#state.request_version,
|
||||||
|
@ -577,7 +577,7 @@ make_xhtml_output(State, Status, Headers, XHTML) ->
|
||||||
end,
|
end,
|
||||||
HeadersOut),
|
HeadersOut),
|
||||||
SL = [Version,
|
SL = [Version,
|
||||||
iolist_to_binary(integer_to_list(Status)), <<" ">>,
|
integer_to_binary(Status), <<" ">>,
|
||||||
code_to_phrase(Status), <<"\r\n">>],
|
code_to_phrase(Status), <<"\r\n">>],
|
||||||
Data2 = case State#state.request_method of
|
Data2 = case State#state.request_method of
|
||||||
'HEAD' -> <<"">>;
|
'HEAD' -> <<"">>;
|
||||||
|
|
|
@ -972,21 +972,17 @@ prepare_outpacket_response(#http_bind{id = Sid,
|
||||||
[{<<"xmlns">>, ?NS_HTTP_BIND},
|
[{<<"xmlns">>, ?NS_HTTP_BIND},
|
||||||
{<<"sid">>, Sid},
|
{<<"sid">>, Sid},
|
||||||
{<<"wait">>,
|
{<<"wait">>,
|
||||||
iolist_to_binary(integer_to_list(Wait))},
|
integer_to_binary(Wait)},
|
||||||
{<<"requests">>,
|
{<<"requests">>,
|
||||||
iolist_to_binary(integer_to_list(Hold
|
integer_to_binary(Hold + 1)},
|
||||||
+
|
|
||||||
1))},
|
|
||||||
{<<"inactivity">>,
|
{<<"inactivity">>,
|
||||||
iolist_to_binary(integer_to_list(trunc(MaxInactivity
|
integer_to_binary(
|
||||||
/
|
trunc(MaxInactivity / 1000))},
|
||||||
1000)))},
|
|
||||||
{<<"maxpause">>,
|
{<<"maxpause">>,
|
||||||
iolist_to_binary(integer_to_list(MaxPause))},
|
integer_to_binary(MaxPause)},
|
||||||
{<<"polling">>,
|
{<<"polling">>,
|
||||||
iolist_to_binary(integer_to_list(trunc((?MIN_POLLING)
|
integer_to_binary(
|
||||||
/
|
trunc((?MIN_POLLING) / 1000000))},
|
||||||
1000000)))},
|
|
||||||
{<<"ver">>, ?BOSH_VERSION},
|
{<<"ver">>, ?BOSH_VERSION},
|
||||||
{<<"from">>, From},
|
{<<"from">>, From},
|
||||||
{<<"secure">>, <<"true">>}]
|
{<<"secure">>, <<"true">>}]
|
||||||
|
|
|
@ -196,7 +196,7 @@ format_scram_password({StoredKey, ServerKey, Salt, IterationCount}) ->
|
||||||
StoredKeyB64 = base64:encode(StoredKey),
|
StoredKeyB64 = base64:encode(StoredKey),
|
||||||
ServerKeyB64 = base64:encode(ServerKey),
|
ServerKeyB64 = base64:encode(ServerKey),
|
||||||
SaltB64 = base64:encode(Salt),
|
SaltB64 = base64:encode(Salt),
|
||||||
IterationCountBin = list_to_binary(integer_to_list(IterationCount)),
|
IterationCountBin = (integer_to_binary(IterationCount)),
|
||||||
<<"scram:", StoredKeyB64/binary, ",", ServerKeyB64/binary, ",", SaltB64/binary, ",", IterationCountBin/binary>>.
|
<<"scram:", StoredKeyB64/binary, ",", ServerKeyB64/binary, ",", SaltB64/binary, ",", IterationCountBin/binary>>.
|
||||||
|
|
||||||
parse_scram_password(PassData) ->
|
parse_scram_password(PassData) ->
|
||||||
|
@ -206,7 +206,7 @@ parse_scram_password(PassData) ->
|
||||||
storedkey = StoredKeyB64,
|
storedkey = StoredKeyB64,
|
||||||
serverkey = ServerKeyB64,
|
serverkey = ServerKeyB64,
|
||||||
salt = SaltB64,
|
salt = SaltB64,
|
||||||
iterationcount = list_to_integer(binary_to_list(IterationCountBin))
|
iterationcount = (binary_to_integer(IterationCountBin))
|
||||||
}.
|
}.
|
||||||
|
|
||||||
-spec get_vcard(binary(), binary()) -> [xmlel()].
|
-spec get_vcard(binary(), binary()) -> [xmlel()].
|
||||||
|
@ -554,9 +554,8 @@ stop(Fmt, Args) ->
|
||||||
|
|
||||||
make_filename_template() ->
|
make_filename_template() ->
|
||||||
{{Year, Month, Day}, {Hour, Minute, Second}} = calendar:local_time(),
|
{{Year, Month, Day}, {Hour, Minute, Second}} = calendar:local_time(),
|
||||||
list_to_binary(
|
str:format("~4..0w~2..0w~2..0w-~2..0w~2..0w~2..0w",
|
||||||
io_lib:format("~4..0w~2..0w~2..0w-~2..0w~2..0w~2..0w",
|
[Year, Month, Day, Hour, Minute, Second]).
|
||||||
[Year, Month, Day, Hour, Minute, Second])).
|
|
||||||
|
|
||||||
make_main_basefilename(Dir, FnT) ->
|
make_main_basefilename(Dir, FnT) ->
|
||||||
Filename2 = <<FnT/binary, ".xml">>,
|
Filename2 = <<FnT/binary, ".xml">>,
|
||||||
|
|
|
@ -428,7 +428,7 @@ map_key(Obj, _, _) ->
|
||||||
<<"b_", B/binary>> ->
|
<<"b_", B/binary>> ->
|
||||||
B;
|
B;
|
||||||
<<"i_", B/binary>> ->
|
<<"i_", B/binary>> ->
|
||||||
list_to_integer(binary_to_list(B));
|
(binary_to_integer(B));
|
||||||
B ->
|
B ->
|
||||||
erlang:binary_to_term(B)
|
erlang:binary_to_term(B)
|
||||||
end].
|
end].
|
||||||
|
@ -483,7 +483,7 @@ encode_index_key(Idx, Key) ->
|
||||||
encode_key(Bin) when is_binary(Bin) ->
|
encode_key(Bin) when is_binary(Bin) ->
|
||||||
<<"b_", Bin/binary>>;
|
<<"b_", Bin/binary>>;
|
||||||
encode_key(Int) when is_integer(Int) ->
|
encode_key(Int) when is_integer(Int) ->
|
||||||
<<"i_", (list_to_binary(integer_to_list(Int)))/binary>>;
|
<<"i_", ((integer_to_binary(Int)))/binary>>;
|
||||||
encode_key(Term) ->
|
encode_key(Term) ->
|
||||||
erlang:term_to_binary(Term).
|
erlang:term_to_binary(Term).
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ log_error(_, _, _) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
make_invalid_object(Val) ->
|
make_invalid_object(Val) ->
|
||||||
list_to_binary(io_lib:fwrite("Invalid object: ~p", [Val])).
|
(str:format("Invalid object: ~p", [Val])).
|
||||||
|
|
||||||
get_random_pid() ->
|
get_random_pid() ->
|
||||||
PoolPid = ejabberd_riak_sup:get_random_pid(),
|
PoolPid = ejabberd_riak_sup:get_random_pid(),
|
||||||
|
|
|
@ -180,10 +180,9 @@ process_large_heap(Pid, Info) ->
|
||||||
Host = (?MYNAME),
|
Host = (?MYNAME),
|
||||||
JIDs = get_admin_jids(),
|
JIDs = get_admin_jids(),
|
||||||
DetailedInfo = detailed_info(Pid),
|
DetailedInfo = detailed_info(Pid),
|
||||||
Body = iolist_to_binary(
|
Body = str:format("(~w) The process ~w is consuming too "
|
||||||
io_lib:format("(~w) The process ~w is consuming too "
|
"much memory:~n~p~n~s",
|
||||||
"much memory:~n~p~n~s",
|
[node(), Pid, Info, DetailedInfo]),
|
||||||
[node(), Pid, Info, DetailedInfo])),
|
|
||||||
From = jid:make(<<"">>, Host, <<"watchdog">>),
|
From = jid:make(<<"">>, Host, <<"watchdog">>),
|
||||||
Hint = [#hint{type = 'no-permanent-store'}],
|
Hint = [#hint{type = 'no-permanent-store'}],
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
|
|
|
@ -763,8 +763,8 @@ process_admin(Host,
|
||||||
[?XAE(<<"form">>,
|
[?XAE(<<"form">>,
|
||||||
[{<<"action">>, <<"">>}, {<<"method">>, <<"post">>}]++direction(ltr),
|
[{<<"action">>, <<"">>}, {<<"method">>, <<"post">>}]++direction(ltr),
|
||||||
[?TEXTAREA(<<"acls">>,
|
[?TEXTAREA(<<"acls">>,
|
||||||
(iolist_to_binary(integer_to_list(lists:max([16,
|
(integer_to_binary(lists:max([16,
|
||||||
NumLines])))),
|
NumLines]))),
|
||||||
<<"80">>, <<(iolist_to_binary(ACLsP))/binary, ".">>),
|
<<"80">>, <<(iolist_to_binary(ACLsP))/binary, ".">>),
|
||||||
?BR,
|
?BR,
|
||||||
?INPUTT(<<"submit">>, <<"submit">>, <<"Submit">>)])],
|
?INPUTT(<<"submit">>, <<"submit">>, <<"Submit">>)])],
|
||||||
|
@ -865,8 +865,8 @@ process_admin(Host,
|
||||||
[?XAE(<<"form">>,
|
[?XAE(<<"form">>,
|
||||||
[{<<"action">>, <<"">>}, {<<"method">>, <<"post">>}]++direction(ltr),
|
[{<<"action">>, <<"">>}, {<<"method">>, <<"post">>}]++direction(ltr),
|
||||||
[?TEXTAREA(<<"access">>,
|
[?TEXTAREA(<<"access">>,
|
||||||
(iolist_to_binary(integer_to_list(lists:max([16,
|
(integer_to_binary(lists:max([16,
|
||||||
NumLines])))),
|
NumLines]))),
|
||||||
<<"80">>, <<(iolist_to_binary(AccessP))/binary, ".">>),
|
<<"80">>, <<(iolist_to_binary(AccessP))/binary, ".">>),
|
||||||
?BR,
|
?BR,
|
||||||
?INPUTT(<<"submit">>, <<"submit">>, <<"Submit">>)])],
|
?INPUTT(<<"submit">>, <<"submit">>, <<"Submit">>)])],
|
||||||
|
@ -926,7 +926,7 @@ process_admin(Host,
|
||||||
Rs1 -> Rs1
|
Rs1 -> Rs1
|
||||||
end,
|
end,
|
||||||
make_xhtml([?XC(<<"h1">>,
|
make_xhtml([?XC(<<"h1">>,
|
||||||
list_to_binary(io_lib:format(
|
(str:format(
|
||||||
?T(<<"~s access rule configuration">>),
|
?T(<<"~s access rule configuration">>),
|
||||||
[SName])))]
|
[SName])))]
|
||||||
++
|
++
|
||||||
|
@ -1141,7 +1141,7 @@ acl_spec_select(ID, Opt) ->
|
||||||
%% @spec (T::any()) -> StringLine::string()
|
%% @spec (T::any()) -> StringLine::string()
|
||||||
term_to_string(T) ->
|
term_to_string(T) ->
|
||||||
StringParagraph =
|
StringParagraph =
|
||||||
iolist_to_binary(io_lib:format("~1000000p", [T])),
|
(str:format("~1000000p", [T])),
|
||||||
ejabberd_regexp:greplace(StringParagraph, <<"\\n ">>,
|
ejabberd_regexp:greplace(StringParagraph, <<"\\n ">>,
|
||||||
<<"">>).
|
<<"">>).
|
||||||
|
|
||||||
|
@ -1506,7 +1506,7 @@ list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
|
||||||
{{Year, Month, Day},
|
{{Year, Month, Day},
|
||||||
{Hour, Minute, Second}} =
|
{Hour, Minute, Second}} =
|
||||||
calendar:now_to_local_time(TimeStamp),
|
calendar:now_to_local_time(TimeStamp),
|
||||||
iolist_to_binary(io_lib:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
|
(str:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
|
||||||
[Year,
|
[Year,
|
||||||
Month,
|
Month,
|
||||||
Day,
|
Day,
|
||||||
|
@ -1683,14 +1683,14 @@ user_info(User, Server, Query, Lang) ->
|
||||||
Shift rem 1000000, 0},
|
Shift rem 1000000, 0},
|
||||||
{{Year, Month, Day}, {Hour, Minute, Second}} =
|
{{Year, Month, Day}, {Hour, Minute, Second}} =
|
||||||
calendar:now_to_local_time(TimeStamp),
|
calendar:now_to_local_time(TimeStamp),
|
||||||
iolist_to_binary(io_lib:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
|
(str:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
|
||||||
[Year, Month, Day,
|
[Year, Month, Day,
|
||||||
Hour, Minute,
|
Hour, Minute,
|
||||||
Second]))
|
Second]))
|
||||||
end;
|
end;
|
||||||
_ -> ?T(<<"Online">>)
|
_ -> ?T(<<"Online">>)
|
||||||
end,
|
end,
|
||||||
[?XC(<<"h1">>, list_to_binary(io_lib:format(?T(<<"User ~s">>),
|
[?XC(<<"h1">>, (str:format(?T(<<"User ~s">>),
|
||||||
[us_to_list(US)])))]
|
[us_to_list(US)])))]
|
||||||
++
|
++
|
||||||
case Res of
|
case Res of
|
||||||
|
@ -1773,9 +1773,7 @@ list_last_activity(Host, Lang, Integral, Period) ->
|
||||||
[?XAE(<<"li">>,
|
[?XAE(<<"li">>,
|
||||||
[{<<"style">>,
|
[{<<"style">>,
|
||||||
<<"width:",
|
<<"width:",
|
||||||
(iolist_to_binary(integer_to_list(trunc(90 * V
|
(integer_to_binary(trunc(90 * V / Max)))/binary,
|
||||||
/
|
|
||||||
Max))))/binary,
|
|
||||||
"%;">>}],
|
"%;">>}],
|
||||||
[{xmlcdata, pretty_string_int(V)}])
|
[{xmlcdata, pretty_string_int(V)}])
|
||||||
|| V <- Hist ++ Tail])]
|
|| V <- Hist ++ Tail])]
|
||||||
|
@ -1850,7 +1848,7 @@ get_node(global, Node, [], Query, Lang) ->
|
||||||
Base = get_base_path(global, Node),
|
Base = get_base_path(global, Node),
|
||||||
MenuItems2 = make_menu_items(global, Node, Base, Lang),
|
MenuItems2 = make_menu_items(global, Node, Base, Lang),
|
||||||
[?XC(<<"h1">>,
|
[?XC(<<"h1">>,
|
||||||
list_to_binary(io_lib:format(?T(<<"Node ~p">>), [Node])))]
|
(str:format(?T(<<"Node ~p">>), [Node])))]
|
||||||
++
|
++
|
||||||
case Res of
|
case Res of
|
||||||
ok -> [?XREST(<<"Submitted">>)];
|
ok -> [?XREST(<<"Submitted">>)];
|
||||||
|
@ -1875,7 +1873,7 @@ get_node(global, Node, [], Query, Lang) ->
|
||||||
get_node(Host, Node, [], _Query, Lang) ->
|
get_node(Host, Node, [], _Query, Lang) ->
|
||||||
Base = get_base_path(Host, Node),
|
Base = get_base_path(Host, Node),
|
||||||
MenuItems2 = make_menu_items(Host, Node, Base, Lang),
|
MenuItems2 = make_menu_items(Host, Node, Base, Lang),
|
||||||
[?XC(<<"h1">>, list_to_binary(io_lib:format(?T(<<"Node ~p">>), [Node]))),
|
[?XC(<<"h1">>, (str:format(?T(<<"Node ~p">>), [Node]))),
|
||||||
?XE(<<"ul">>,
|
?XE(<<"ul">>,
|
||||||
([?LI([?ACT(<<Base/binary, "modules/">>,
|
([?LI([?ACT(<<Base/binary, "modules/">>,
|
||||||
<<"Modules">>)])]
|
<<"Modules">>)])]
|
||||||
|
@ -1934,7 +1932,7 @@ get_node(global, Node, [<<"db">>], Query, Lang) ->
|
||||||
end,
|
end,
|
||||||
STables),
|
STables),
|
||||||
[?XC(<<"h1">>,
|
[?XC(<<"h1">>,
|
||||||
list_to_binary(io_lib:format(?T(<<"Database Tables at ~p">>),
|
(str:format(?T(<<"Database Tables at ~p">>),
|
||||||
[Node]))
|
[Node]))
|
||||||
)]
|
)]
|
||||||
++
|
++
|
||||||
|
@ -1970,9 +1968,9 @@ get_node(global, Node, [<<"backup">>], Query, Lang) ->
|
||||||
ok -> [?XREST(<<"Submitted">>)];
|
ok -> [?XREST(<<"Submitted">>)];
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
[?XRES(<<(?T(<<"Error">>))/binary, ": ",
|
[?XRES(<<(?T(<<"Error">>))/binary, ": ",
|
||||||
(list_to_binary(io_lib:format("~p", [Error])))/binary>>)]
|
((str:format("~p", [Error])))/binary>>)]
|
||||||
end,
|
end,
|
||||||
[?XC(<<"h1">>, list_to_binary(io_lib:format(?T(<<"Backup of ~p">>), [Node])))]
|
[?XC(<<"h1">>, (str:format(?T(<<"Backup of ~p">>), [Node])))]
|
||||||
++
|
++
|
||||||
ResS ++
|
ResS ++
|
||||||
[?XCT(<<"p">>,
|
[?XCT(<<"p">>,
|
||||||
|
@ -2124,7 +2122,7 @@ get_node(global, Node, [<<"ports">>], Query, Lang) ->
|
||||||
{'EXIT', _Reason} -> error;
|
{'EXIT', _Reason} -> error;
|
||||||
{is_added, ok} -> ok;
|
{is_added, ok} -> ok;
|
||||||
{is_added, {error, Reason}} ->
|
{is_added, {error, Reason}} ->
|
||||||
{error, iolist_to_binary(io_lib:format("~p", [Reason]))};
|
{error, (str:format("~p", [Reason]))};
|
||||||
_ -> nothing
|
_ -> nothing
|
||||||
end,
|
end,
|
||||||
NewPorts = lists:sort(ejabberd_cluster:call(Node, ejabberd_config,
|
NewPorts = lists:sort(ejabberd_cluster:call(Node, ejabberd_config,
|
||||||
|
@ -2161,7 +2159,7 @@ get_node(Host, Node, [<<"modules">>], Query, Lang)
|
||||||
end,
|
end,
|
||||||
NewModules = lists:sort(ejabberd_cluster:call(Node, gen_mod,
|
NewModules = lists:sort(ejabberd_cluster:call(Node, gen_mod,
|
||||||
loaded_modules_with_opts, [Host])),
|
loaded_modules_with_opts, [Host])),
|
||||||
H1String = list_to_binary(io_lib:format(?T(<<"Modules at ~p">>), [Node])),
|
H1String = (str:format(?T(<<"Modules at ~p">>), [Node])),
|
||||||
(?H1GL(H1String, <<"modulesoverview">>,
|
(?H1GL(H1String, <<"modulesoverview">>,
|
||||||
<<"Modules Overview">>))
|
<<"Modules Overview">>))
|
||||||
++
|
++
|
||||||
|
@ -2177,10 +2175,10 @@ get_node(Host, Node, [<<"modules">>], Query, Lang)
|
||||||
get_node(global, Node, [<<"stats">>], _Query, Lang) ->
|
get_node(global, Node, [<<"stats">>], _Query, Lang) ->
|
||||||
UpTime = ejabberd_cluster:call(Node, erlang, statistics,
|
UpTime = ejabberd_cluster:call(Node, erlang, statistics,
|
||||||
[wall_clock]),
|
[wall_clock]),
|
||||||
UpTimeS = list_to_binary(io_lib:format("~.3f",
|
UpTimeS = (str:format("~.3f",
|
||||||
[element(1, UpTime) / 1000])),
|
[element(1, UpTime) / 1000])),
|
||||||
CPUTime = ejabberd_cluster:call(Node, erlang, statistics, [runtime]),
|
CPUTime = ejabberd_cluster:call(Node, erlang, statistics, [runtime]),
|
||||||
CPUTimeS = list_to_binary(io_lib:format("~.3f",
|
CPUTimeS = (str:format("~.3f",
|
||||||
[element(1, CPUTime) / 1000])),
|
[element(1, CPUTime) / 1000])),
|
||||||
OnlineUsers = ejabberd_sm:connected_users_number(),
|
OnlineUsers = ejabberd_sm:connected_users_number(),
|
||||||
TransactionsCommitted = ejabberd_cluster:call(Node, mnesia,
|
TransactionsCommitted = ejabberd_cluster:call(Node, mnesia,
|
||||||
|
@ -2192,7 +2190,7 @@ get_node(global, Node, [<<"stats">>], _Query, Lang) ->
|
||||||
TransactionsLogged = ejabberd_cluster:call(Node, mnesia, system_info,
|
TransactionsLogged = ejabberd_cluster:call(Node, mnesia, system_info,
|
||||||
[transaction_log_writes]),
|
[transaction_log_writes]),
|
||||||
[?XC(<<"h1">>,
|
[?XC(<<"h1">>,
|
||||||
list_to_binary(io_lib:format(?T(<<"Statistics of ~p">>), [Node]))),
|
(str:format(?T(<<"Statistics of ~p">>), [Node]))),
|
||||||
?XAE(<<"table">>, [],
|
?XAE(<<"table">>, [],
|
||||||
[?XE(<<"tbody">>,
|
[?XE(<<"tbody">>,
|
||||||
[?XE(<<"tr">>,
|
[?XE(<<"tr">>,
|
||||||
|
@ -2256,11 +2254,11 @@ get_node(global, Node, [<<"update">>], Query, Lang) ->
|
||||||
(BeamsLis ++ SelectButtons))
|
(BeamsLis ++ SelectButtons))
|
||||||
end,
|
end,
|
||||||
FmtScript = (?XC(<<"pre">>,
|
FmtScript = (?XC(<<"pre">>,
|
||||||
list_to_binary(io_lib:format("~p", [Script])))),
|
(str:format("~p", [Script])))),
|
||||||
FmtLowLevelScript = (?XC(<<"pre">>,
|
FmtLowLevelScript = (?XC(<<"pre">>,
|
||||||
list_to_binary(io_lib:format("~p", [LowLevelScript])))),
|
(str:format("~p", [LowLevelScript])))),
|
||||||
[?XC(<<"h1">>,
|
[?XC(<<"h1">>,
|
||||||
list_to_binary(io_lib:format(?T(<<"Update ~p">>), [Node])))]
|
(str:format(?T(<<"Update ~p">>), [Node])))]
|
||||||
++
|
++
|
||||||
case Res of
|
case Res of
|
||||||
ok -> [?XREST(<<"Submitted">>)];
|
ok -> [?XREST(<<"Submitted">>)];
|
||||||
|
@ -2482,7 +2480,7 @@ node_ports_to_xhtml(Ports, Lang) ->
|
||||||
SModule, <<"15">>)]),
|
SModule, <<"15">>)]),
|
||||||
?XAE(<<"td">>, direction(ltr),
|
?XAE(<<"td">>, direction(ltr),
|
||||||
[?TEXTAREA(<<"opts", SSPort/binary>>,
|
[?TEXTAREA(<<"opts", SSPort/binary>>,
|
||||||
(iolist_to_binary(integer_to_list(NumLines))),
|
(integer_to_binary(NumLines)),
|
||||||
<<"35">>, SOptsClean)]),
|
<<"35">>, SOptsClean)]),
|
||||||
?XE(<<"td">>,
|
?XE(<<"td">>,
|
||||||
[?INPUTT(<<"submit">>,
|
[?INPUTT(<<"submit">>,
|
||||||
|
@ -2625,7 +2623,7 @@ node_modules_to_xhtml(Modules, Lang) ->
|
||||||
[?XC(<<"td">>, SModule),
|
[?XC(<<"td">>, SModule),
|
||||||
?XAE(<<"td">>, direction(ltr),
|
?XAE(<<"td">>, direction(ltr),
|
||||||
[?TEXTAREA(<<"opts", SModule/binary>>,
|
[?TEXTAREA(<<"opts", SModule/binary>>,
|
||||||
(iolist_to_binary(integer_to_list(NumLines))),
|
(integer_to_binary(NumLines)),
|
||||||
<<"40">>, SOpts)]),
|
<<"40">>, SOpts)]),
|
||||||
?XE(<<"td">>,
|
?XE(<<"td">>,
|
||||||
[?INPUTT(<<"submit">>,
|
[?INPUTT(<<"submit">>,
|
||||||
|
@ -2707,11 +2705,11 @@ node_update_parse_query(Node, Query) ->
|
||||||
{ok, _} -> ok;
|
{ok, _} -> ok;
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
?ERROR_MSG("~p~n", [Error]),
|
?ERROR_MSG("~p~n", [Error]),
|
||||||
{error, iolist_to_binary(io_lib:format("~p", [Error]))};
|
{error, (str:format("~p", [Error]))};
|
||||||
{badrpc, Error} ->
|
{badrpc, Error} ->
|
||||||
?ERROR_MSG("Bad RPC: ~p~n", [Error]),
|
?ERROR_MSG("Bad RPC: ~p~n", [Error]),
|
||||||
{error,
|
{error,
|
||||||
<<"Bad RPC: ", (iolist_to_binary(io_lib:format("~p", [Error])))/binary>>}
|
<<"Bad RPC: ", ((str:format("~p", [Error])))/binary>>}
|
||||||
end;
|
end;
|
||||||
_ -> nothing
|
_ -> nothing
|
||||||
end.
|
end.
|
||||||
|
@ -2776,7 +2774,7 @@ pretty_print_xml(#xmlel{name = Name, attrs = Attrs,
|
||||||
element_to_list(X) when is_atom(X) ->
|
element_to_list(X) when is_atom(X) ->
|
||||||
iolist_to_binary(atom_to_list(X));
|
iolist_to_binary(atom_to_list(X));
|
||||||
element_to_list(X) when is_integer(X) ->
|
element_to_list(X) when is_integer(X) ->
|
||||||
iolist_to_binary(integer_to_list(X)).
|
integer_to_binary(X).
|
||||||
|
|
||||||
list_to_element(Bin) ->
|
list_to_element(Bin) ->
|
||||||
{ok, Tokens, _} = erl_scan:string(binary_to_list(Bin)),
|
{ok, Tokens, _} = erl_scan:string(binary_to_list(Bin)),
|
||||||
|
@ -2784,8 +2782,8 @@ list_to_element(Bin) ->
|
||||||
Element.
|
Element.
|
||||||
|
|
||||||
url_func({user_diapason, From, To}) ->
|
url_func({user_diapason, From, To}) ->
|
||||||
<<(iolist_to_binary(integer_to_list(From)))/binary, "-",
|
<<(integer_to_binary(From))/binary, "-",
|
||||||
(iolist_to_binary(integer_to_list(To)))/binary, "/">>;
|
(integer_to_binary(To))/binary, "/">>;
|
||||||
url_func({users_queue, Prefix, User, _Server}) ->
|
url_func({users_queue, Prefix, User, _Server}) ->
|
||||||
<<Prefix/binary, "user/", User/binary, "/queue/">>;
|
<<Prefix/binary, "user/", User/binary, "/queue/">>;
|
||||||
url_func({user, Prefix, User, _Server}) ->
|
url_func({user, Prefix, User, _Server}) ->
|
||||||
|
@ -2800,7 +2798,7 @@ cache_control_public() ->
|
||||||
|
|
||||||
%% Transform 1234567890 into "1,234,567,890"
|
%% Transform 1234567890 into "1,234,567,890"
|
||||||
pretty_string_int(Integer) when is_integer(Integer) ->
|
pretty_string_int(Integer) when is_integer(Integer) ->
|
||||||
pretty_string_int(iolist_to_binary(integer_to_list(Integer)));
|
pretty_string_int(integer_to_binary(Integer));
|
||||||
pretty_string_int(String) when is_binary(String) ->
|
pretty_string_int(String) when is_binary(String) ->
|
||||||
{_, Result} = lists:foldl(fun (NewNumber, {3, Result}) ->
|
{_, Result} = lists:foldl(fun (NewNumber, {3, Result}) ->
|
||||||
{1, <<NewNumber, $,, Result/binary>>};
|
{1, <<NewNumber, $,, Result/binary>>};
|
||||||
|
|
|
@ -677,14 +677,14 @@ timestamp_to_iso({{Year, Month, Day},
|
||||||
%% http://xmpp.org/extensions/xep-0091.html#time
|
%% http://xmpp.org/extensions/xep-0091.html#time
|
||||||
timestamp_to_legacy({{Year, Month, Day},
|
timestamp_to_legacy({{Year, Month, Day},
|
||||||
{Hour, Minute, Second}}) ->
|
{Hour, Minute, Second}}) ->
|
||||||
iolist_to_binary(io_lib:format("~4..0B~2..0B~2..0BT~2..0B:~2..0B:~2..0B",
|
(str:format("~4..0B~2..0B~2..0BT~2..0B:~2..0B:~2..0B",
|
||||||
[Year, Month, Day, Hour, Minute, Second])).
|
[Year, Month, Day, Hour, Minute, Second])).
|
||||||
|
|
||||||
-spec timestamp_to_iso_basic(calendar:datetime()) -> binary().
|
-spec timestamp_to_iso_basic(calendar:datetime()) -> binary().
|
||||||
%% This is the ISO 8601 basic bormat
|
%% This is the ISO 8601 basic bormat
|
||||||
timestamp_to_iso_basic({{Year, Month, Day},
|
timestamp_to_iso_basic({{Year, Month, Day},
|
||||||
{Hour, Minute, Second}}) ->
|
{Hour, Minute, Second}}) ->
|
||||||
iolist_to_binary(io_lib:format("~4..0B~2..0B~2..0BT~2..0B~2..0B~2..0B",
|
(str:format("~4..0B~2..0B~2..0BT~2..0B~2..0B~2..0B",
|
||||||
[Year, Month, Day, Hour, Minute, Second])).
|
[Year, Month, Day, Hour, Minute, Second])).
|
||||||
|
|
||||||
-spec now_to_utc_string(erlang:timestamp()) -> binary().
|
-spec now_to_utc_string(erlang:timestamp()) -> binary().
|
||||||
|
@ -703,7 +703,7 @@ now_to_utc_string({MegaSecs, Secs, MicroSecs}, Precision) ->
|
||||||
Max ->
|
Max ->
|
||||||
now_to_utc_string({MegaSecs, Secs + 1, 0}, Precision);
|
now_to_utc_string({MegaSecs, Secs + 1, 0}, Precision);
|
||||||
FracOfSec ->
|
FracOfSec ->
|
||||||
list_to_binary(io_lib:format("~4..0B-~2..0B-~2..0BT"
|
(str:format("~4..0B-~2..0B-~2..0BT"
|
||||||
"~2..0B:~2..0B:~2..0B.~*..0BZ",
|
"~2..0B:~2..0B:~2..0B.~*..0BZ",
|
||||||
[Year, Month, Day, Hour, Minute, Second,
|
[Year, Month, Day, Hour, Minute, Second,
|
||||||
Precision, FracOfSec]))
|
Precision, FracOfSec]))
|
||||||
|
@ -725,7 +725,7 @@ now_to_local_string({MegaSecs, Secs, MicroSecs}) ->
|
||||||
end,
|
end,
|
||||||
{{Year, Month, Day}, {Hour, Minute, Second}} =
|
{{Year, Month, Day}, {Hour, Minute, Second}} =
|
||||||
LocalTime,
|
LocalTime,
|
||||||
list_to_binary(io_lib:format("~4..0B-~2..0B-~2..0BT~2..0B:~2..0B:~2..0B.~6."
|
(str:format("~4..0B-~2..0B-~2..0BT~2..0B:~2..0B:~2..0B.~6."
|
||||||
".0B~s~2..0B:~2..0B",
|
".0B~s~2..0B:~2..0B",
|
||||||
[Year, Month, Day, Hour, Minute, Second,
|
[Year, Month, Day, Hour, Minute, Second,
|
||||||
MicroSecs, Sign, H, M])).
|
MicroSecs, Sign, H, M])).
|
||||||
|
|
|
@ -680,9 +680,9 @@ get_all_vh_users(Host) ->
|
||||||
lists:map(fun (K) ->
|
lists:map(fun (K) ->
|
||||||
L = K + M - 1,
|
L = K + M - 1,
|
||||||
Node = <<"@",
|
Node = <<"@",
|
||||||
(iolist_to_binary(integer_to_list(K)))/binary,
|
(integer_to_binary(K))/binary,
|
||||||
"-",
|
"-",
|
||||||
(iolist_to_binary(integer_to_list(L)))/binary>>,
|
(integer_to_binary(L))/binary>>,
|
||||||
{FS, FU} = lists:nth(K, SUsers),
|
{FS, FU} = lists:nth(K, SUsers),
|
||||||
{LS, LU} = if L < N -> lists:nth(L, SUsers);
|
{LS, LU} = if L < N -> lists:nth(L, SUsers);
|
||||||
true -> lists:last(SUsers)
|
true -> lists:last(SUsers)
|
||||||
|
@ -707,8 +707,7 @@ get_outgoing_s2s(Host, Lang) ->
|
||||||
Host == FH orelse str:suffix(DotHost, FH)],
|
Host == FH orelse str:suffix(DotHost, FH)],
|
||||||
lists:map(
|
lists:map(
|
||||||
fun (T) ->
|
fun (T) ->
|
||||||
Name = iolist_to_binary(
|
Name = str:format(?T(Lang, <<"To ~s">>),[T]),
|
||||||
io_lib:format(?T(Lang, <<"To ~s">>),[T])),
|
|
||||||
#disco_item{jid = jid:make(Host),
|
#disco_item{jid = jid:make(Host),
|
||||||
node = <<"outgoing s2s/", T/binary>>,
|
node = <<"outgoing s2s/", T/binary>>,
|
||||||
name = Name}
|
name = Name}
|
||||||
|
@ -722,8 +721,7 @@ get_outgoing_s2s(Host, Lang, To) ->
|
||||||
lists:map(
|
lists:map(
|
||||||
fun ({F, _T}) ->
|
fun ({F, _T}) ->
|
||||||
Node = <<"outgoing s2s/", To/binary, "/", F/binary>>,
|
Node = <<"outgoing s2s/", To/binary, "/", F/binary>>,
|
||||||
Name = iolist_to_binary(
|
Name = str:format(?T(Lang, <<"From ~s">>), [F]),
|
||||||
io_lib:format(?T(Lang, <<"From ~s">>), [F])),
|
|
||||||
#disco_item{jid = jid:make(Host), node = Node, name = Name}
|
#disco_item{jid = jid:make(Host), node = Node, name = Name}
|
||||||
end,
|
end,
|
||||||
lists:keysort(1,
|
lists:keysort(1,
|
||||||
|
@ -1082,14 +1080,13 @@ get_form(_Host,
|
||||||
label = ?T(Lang, <<"Message body">>)}]}};
|
label = ?T(Lang, <<"Message body">>)}]}};
|
||||||
get_form(Host, [<<"config">>, <<"acls">>], Lang) ->
|
get_form(Host, [<<"config">>, <<"acls">>], Lang) ->
|
||||||
ACLs = str:tokens(
|
ACLs = str:tokens(
|
||||||
iolist_to_binary(
|
str:format("~p.",
|
||||||
io_lib:format("~p.",
|
[mnesia:dirty_select(
|
||||||
[mnesia:dirty_select(
|
acl,
|
||||||
acl,
|
ets:fun2ms(
|
||||||
ets:fun2ms(
|
fun({acl, {Name, H}, Spec}) when H == Host ->
|
||||||
fun({acl, {Name, H}, Spec}) when H == Host ->
|
{acl, Name, Spec}
|
||||||
{acl, Name, Spec}
|
end))]),
|
||||||
end))])),
|
|
||||||
<<"\n">>),
|
<<"\n">>),
|
||||||
{result,
|
{result,
|
||||||
#xdata{title = ?T(Lang, <<"Access Control List Configuration">>),
|
#xdata{title = ?T(Lang, <<"Access Control List Configuration">>),
|
||||||
|
@ -1101,14 +1098,13 @@ get_form(Host, [<<"config">>, <<"acls">>], Lang) ->
|
||||||
values = ACLs}]}};
|
values = ACLs}]}};
|
||||||
get_form(Host, [<<"config">>, <<"access">>], Lang) ->
|
get_form(Host, [<<"config">>, <<"access">>], Lang) ->
|
||||||
Accs = str:tokens(
|
Accs = str:tokens(
|
||||||
iolist_to_binary(
|
str:format("~p.",
|
||||||
io_lib:format("~p.",
|
[mnesia:dirty_select(
|
||||||
[mnesia:dirty_select(
|
access,
|
||||||
access,
|
ets:fun2ms(
|
||||||
ets:fun2ms(
|
fun({access, {Name, H}, Acc}) when H == Host ->
|
||||||
fun({access, {Name, H}, Acc}) when H == Host ->
|
{access, Name, Acc}
|
||||||
{access, Name, Acc}
|
end))]),
|
||||||
end))])),
|
|
||||||
<<"\n">>),
|
<<"\n">>),
|
||||||
{result,
|
{result,
|
||||||
#xdata{title = ?T(Lang, <<"Access Configuration">>),
|
#xdata{title = ?T(Lang, <<"Access Configuration">>),
|
||||||
|
@ -1199,9 +1195,7 @@ get_form(_Host, ?NS_ADMINL(<<"user-stats">>), Lang) ->
|
||||||
required = true}]}};
|
required = true}]}};
|
||||||
get_form(Host,
|
get_form(Host,
|
||||||
?NS_ADMINL(<<"get-registered-users-num">>), Lang) ->
|
?NS_ADMINL(<<"get-registered-users-num">>), Lang) ->
|
||||||
Num = list_to_binary(
|
Num = integer_to_binary(ejabberd_auth:get_vh_registered_users_number(Host)),
|
||||||
io_lib:format("~p",
|
|
||||||
[ejabberd_auth:get_vh_registered_users_number(Host)])),
|
|
||||||
{result, completed,
|
{result, completed,
|
||||||
#xdata{type = form,
|
#xdata{type = form,
|
||||||
fields = [?HFIELD(),
|
fields = [?HFIELD(),
|
||||||
|
@ -1211,9 +1205,7 @@ get_form(Host,
|
||||||
values = [Num]}]}};
|
values = [Num]}]}};
|
||||||
get_form(Host, ?NS_ADMINL(<<"get-online-users-num">>),
|
get_form(Host, ?NS_ADMINL(<<"get-online-users-num">>),
|
||||||
Lang) ->
|
Lang) ->
|
||||||
Num = list_to_binary(
|
Num = integer_to_binary(ejabberd_sm:get_vh_session_number(Host)),
|
||||||
io_lib:format("~p",
|
|
||||||
[length(ejabberd_sm:get_vh_session_list(Host))])),
|
|
||||||
{result, completed,
|
{result, completed,
|
||||||
#xdata{type = form,
|
#xdata{type = form,
|
||||||
fields = [?HFIELD(),
|
fields = [?HFIELD(),
|
||||||
|
@ -1641,7 +1633,7 @@ set_form(From, Host,
|
||||||
TimeStamp = {Shift div 1000000, Shift rem 1000000, 0},
|
TimeStamp = {Shift div 1000000, Shift rem 1000000, 0},
|
||||||
{{Year, Month, Day}, {Hour, Minute, Second}} =
|
{{Year, Month, Day}, {Hour, Minute, Second}} =
|
||||||
calendar:now_to_local_time(TimeStamp),
|
calendar:now_to_local_time(TimeStamp),
|
||||||
iolist_to_binary(io_lib:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
|
(str:format("~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
|
||||||
[Year, Month, Day, Hour,
|
[Year, Month, Day, Hour,
|
||||||
Minute, Second]))
|
Minute, Second]))
|
||||||
end;
|
end;
|
||||||
|
|
|
@ -464,24 +464,23 @@ get_form(ServerHost, Host, From, Lang) ->
|
||||||
var = <<"username">>,
|
var = <<"username">>,
|
||||||
values = [Username]},
|
values = [Username]},
|
||||||
#xdata_field{type = fixed,
|
#xdata_field{type = fixed,
|
||||||
values = [iolist_to_binary(
|
values = [str:format(
|
||||||
io_lib:format(
|
translate:translate(
|
||||||
translate:translate(
|
Lang,
|
||||||
Lang,
|
<<"If you want to specify"
|
||||||
<<"If you want to specify"
|
" different ports, "
|
||||||
" different ports, "
|
"passwords, encodings "
|
||||||
"passwords, encodings "
|
"for IRC servers, "
|
||||||
"for IRC servers, "
|
"fill this list with "
|
||||||
"fill this list with "
|
"values in format "
|
||||||
"values in format "
|
"'{\"irc server\", "
|
||||||
"'{\"irc server\", "
|
"\"encoding\", port, "
|
||||||
"\"encoding\", port, "
|
"\"password\"}'. "
|
||||||
"\"password\"}'. "
|
"By default this "
|
||||||
"By default this "
|
"service use \"~s\" "
|
||||||
"service use \"~s\" "
|
"encoding, port ~p, "
|
||||||
"encoding, port ~p, "
|
"empty password.">>),
|
||||||
"empty password.">>),
|
[DefaultEncoding, ?DEFAULT_IRC_PORT])]},
|
||||||
[DefaultEncoding, ?DEFAULT_IRC_PORT]))]},
|
|
||||||
#xdata_field{type = fixed,
|
#xdata_field{type = fixed,
|
||||||
values = [translate:translate(
|
values = [translate:translate(
|
||||||
Lang,
|
Lang,
|
||||||
|
@ -493,11 +492,10 @@ get_form(ServerHost, Host, From, Lang) ->
|
||||||
label = translate:translate(
|
label = translate:translate(
|
||||||
Lang, <<"Connections parameters">>),
|
Lang, <<"Connections parameters">>),
|
||||||
var = <<"connections_params">>,
|
var = <<"connections_params">>,
|
||||||
values = str:tokens(list_to_binary(
|
values = str:tokens(str:format(
|
||||||
io_lib:format(
|
"~p.",
|
||||||
"~p.",
|
[conn_params_to_list(
|
||||||
[conn_params_to_list(
|
ConnectionsParams)]),
|
||||||
ConnectionsParams)])),
|
|
||||||
<<"\n">>)}],
|
<<"\n">>)}],
|
||||||
X = #xdata{type = form,
|
X = #xdata{type = form,
|
||||||
title = <<(translate:translate(
|
title = <<(translate:translate(
|
||||||
|
@ -657,11 +655,10 @@ adhoc_join(From, To, #adhoc_command{lang = Lang, xdata = X} = Request) ->
|
||||||
RoomJID = jid:make(<<Channel/binary, "%", Server/binary>>,
|
RoomJID = jid:make(<<Channel/binary, "%", Server/binary>>,
|
||||||
To#jid.server),
|
To#jid.server),
|
||||||
Reason = translate:translate(Lang, <<"Join the IRC channel here.">>),
|
Reason = translate:translate(Lang, <<"Join the IRC channel here.">>),
|
||||||
Body = iolist_to_binary(
|
Body = str:format(
|
||||||
io_lib:format(
|
translate:translate(
|
||||||
translate:translate(
|
Lang, <<"Join the IRC channel in this Jabber ID: ~s">>),
|
||||||
Lang, <<"Join the IRC channel in this Jabber ID: ~s">>),
|
[jid:to_string(RoomJID)]),
|
||||||
[jid:to_string(RoomJID)])),
|
|
||||||
Invite = #message{
|
Invite = #message{
|
||||||
body = xmpp:mk_text(Body, Lang),
|
body = xmpp:mk_text(Body, Lang),
|
||||||
sub_els = [#muc_user{
|
sub_els = [#muc_user{
|
||||||
|
@ -782,43 +779,37 @@ generate_connection_params_field(Lang, Server, Encoding,
|
||||||
Port;
|
Port;
|
||||||
true -> ?DEFAULT_IRC_PORT
|
true -> ?DEFAULT_IRC_PORT
|
||||||
end,
|
end,
|
||||||
PortUsed =
|
PortUsed = integer_to_binary(PortUsedInt),
|
||||||
iolist_to_binary(integer_to_list(PortUsedInt)),
|
|
||||||
PasswordUsed = case Password of
|
PasswordUsed = case Password of
|
||||||
<<>> -> <<>>;
|
<<>> -> <<>>;
|
||||||
_ -> Password
|
_ -> Password
|
||||||
end,
|
end,
|
||||||
NumberString =
|
NumberString = integer_to_binary(Number),
|
||||||
iolist_to_binary(integer_to_list(Number)),
|
|
||||||
[#xdata_field{var = <<"password", NumberString/binary>>,
|
[#xdata_field{var = <<"password", NumberString/binary>>,
|
||||||
type = 'text-single',
|
type = 'text-single',
|
||||||
label = iolist_to_binary(
|
label = str:format(
|
||||||
io_lib:format(
|
translate:translate(Lang, <<"Password ~b">>),
|
||||||
translate:translate(Lang, <<"Password ~b">>),
|
[Number]),
|
||||||
[Number])),
|
|
||||||
values = [PasswordUsed]},
|
values = [PasswordUsed]},
|
||||||
#xdata_field{var = <<"port", NumberString/binary>>,
|
#xdata_field{var = <<"port", NumberString/binary>>,
|
||||||
type = 'text-single',
|
type = 'text-single',
|
||||||
label = iolist_to_binary(
|
label = str:format(
|
||||||
io_lib:format(
|
translate:translate(Lang, <<"Port ~b">>),
|
||||||
translate:translate(Lang, <<"Port ~b">>),
|
[Number]),
|
||||||
[Number])),
|
|
||||||
values = [PortUsed]},
|
values = [PortUsed]},
|
||||||
#xdata_field{var = <<"encoding", NumberString/binary>>,
|
#xdata_field{var = <<"encoding", NumberString/binary>>,
|
||||||
type = 'list-single',
|
type = 'list-single',
|
||||||
label = list_to_binary(
|
label = str:format(
|
||||||
io_lib:format(
|
translate:translate(Lang, <<"Encoding for server ~b">>),
|
||||||
translate:translate(Lang, <<"Encoding for server ~b">>),
|
[Number]),
|
||||||
[Number])),
|
|
||||||
values = [EncodingUsed],
|
values = [EncodingUsed],
|
||||||
options = [#xdata_option{label = E, value = E}
|
options = [#xdata_option{label = E, value = E}
|
||||||
|| E <- ?POSSIBLE_ENCODINGS]},
|
|| E <- ?POSSIBLE_ENCODINGS]},
|
||||||
#xdata_field{var = <<"server", NumberString/binary>>,
|
#xdata_field{var = <<"server", NumberString/binary>>,
|
||||||
type = 'text-single',
|
type = 'text-single',
|
||||||
label = list_to_binary(
|
label = str:format(
|
||||||
io_lib:format(
|
translate:translate(Lang, <<"Server ~b">>),
|
||||||
translate:translate(Lang, <<"Server ~b">>),
|
[Number]),
|
||||||
[Number])),
|
|
||||||
values = [Server]}].
|
values = [Server]}].
|
||||||
|
|
||||||
parse_connections_params(#xdata{fields = Fields}) ->
|
parse_connections_params(#xdata{fields = Fields}) ->
|
||||||
|
|
|
@ -1213,5 +1213,5 @@ unixtime2string(Unixtime) ->
|
||||||
{0, 0, 0}}),
|
{0, 0, 0}}),
|
||||||
{{Year, Month, Day}, {Hour, Minute, Second}} =
|
{{Year, Month, Day}, {Hour, Minute, Second}} =
|
||||||
calendar:universal_time_to_local_time(calendar:gregorian_seconds_to_datetime(Secs)),
|
calendar:universal_time_to_local_time(calendar:gregorian_seconds_to_datetime(Secs)),
|
||||||
iolist_to_binary(io_lib:format("~4..0w-~2..0w-~2..0w ~2..0w:~2..0w:~2..0w",
|
(str:format("~4..0w-~2..0w-~2..0w ~2..0w:~2..0w:~2..0w",
|
||||||
[Year, Month, Day, Hour, Minute, Second])).
|
[Year, Month, Day, Hour, Minute, Second])).
|
||||||
|
|
|
@ -247,18 +247,18 @@ build_filename_string(TimeStamp, OutDir, RoomJID,
|
||||||
{Dir, Filename, Rel} = case DirType of
|
{Dir, Filename, Rel} = case DirType of
|
||||||
subdirs ->
|
subdirs ->
|
||||||
SYear =
|
SYear =
|
||||||
iolist_to_binary(io_lib:format("~4..0w",
|
(str:format("~4..0w",
|
||||||
[Year])),
|
[Year])),
|
||||||
SMonth =
|
SMonth =
|
||||||
iolist_to_binary(io_lib:format("~2..0w",
|
(str:format("~2..0w",
|
||||||
[Month])),
|
[Month])),
|
||||||
SDay = iolist_to_binary(io_lib:format("~2..0w",
|
SDay = (str:format("~2..0w",
|
||||||
[Day])),
|
[Day])),
|
||||||
{fjoin([SYear, SMonth]), SDay,
|
{fjoin([SYear, SMonth]), SDay,
|
||||||
<<"../..">>};
|
<<"../..">>};
|
||||||
plain ->
|
plain ->
|
||||||
Date =
|
Date =
|
||||||
iolist_to_binary(io_lib:format("~4..0w-~2..0w-~2..0w",
|
(str:format("~4..0w-~2..0w-~2..0w",
|
||||||
[Year,
|
[Year,
|
||||||
Month,
|
Month,
|
||||||
Day])),
|
Day])),
|
||||||
|
@ -727,7 +727,7 @@ fw(F, S, FileFormat) when is_atom(FileFormat) ->
|
||||||
fw(F, S, [], FileFormat).
|
fw(F, S, [], FileFormat).
|
||||||
|
|
||||||
fw(F, S, O, FileFormat) ->
|
fw(F, S, O, FileFormat) ->
|
||||||
S1 = list_to_binary(io_lib:format(binary_to_list(S) ++ "~n", O)),
|
S1 = (str:format(binary_to_list(S) ++ "~n", O)),
|
||||||
S2 = case FileFormat of
|
S2 = case FileFormat of
|
||||||
html ->
|
html ->
|
||||||
S1;
|
S1;
|
||||||
|
|
|
@ -717,7 +717,7 @@ user_queue(User, Server, Query, Lang) ->
|
||||||
Hdrs = get_messages_subset(US, Server, HdrsAll),
|
Hdrs = get_messages_subset(US, Server, HdrsAll),
|
||||||
FMsgs = format_user_queue(Hdrs),
|
FMsgs = format_user_queue(Hdrs),
|
||||||
[?XC(<<"h1">>,
|
[?XC(<<"h1">>,
|
||||||
list_to_binary(io_lib:format(?T(<<"~s's Offline Messages Queue">>),
|
(str:format(?T(<<"~s's Offline Messages Queue">>),
|
||||||
[us_to_list(US)])))]
|
[us_to_list(US)])))]
|
||||||
++
|
++
|
||||||
case Res of
|
case Res of
|
||||||
|
@ -801,7 +801,7 @@ webadmin_user(Acc, User, Server, Lang) ->
|
||||||
QueueLen = count_offline_messages(jid:nodeprep(User),
|
QueueLen = count_offline_messages(jid:nodeprep(User),
|
||||||
jid:nameprep(Server)),
|
jid:nameprep(Server)),
|
||||||
FQueueLen = [?AC(<<"queue/">>,
|
FQueueLen = [?AC(<<"queue/">>,
|
||||||
(iolist_to_binary(integer_to_list(QueueLen))))],
|
(integer_to_binary(QueueLen)))],
|
||||||
Acc ++
|
Acc ++
|
||||||
[?XCT(<<"h3">>, <<"Offline Messages:">>)] ++
|
[?XCT(<<"h3">>, <<"Offline Messages:">>)] ++
|
||||||
FQueueLen ++
|
FQueueLen ++
|
||||||
|
|
|
@ -3776,7 +3776,7 @@ err_unsupported_access_model() ->
|
||||||
-spec uniqid() -> mod_pubsub:itemId().
|
-spec uniqid() -> mod_pubsub:itemId().
|
||||||
uniqid() ->
|
uniqid() ->
|
||||||
{T1, T2, T3} = p1_time_compat:timestamp(),
|
{T1, T2, T3} = p1_time_compat:timestamp(),
|
||||||
iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])).
|
(str:format("~.16B~.16B~.16B", [T1, T2, T3])).
|
||||||
|
|
||||||
-spec itemsEls([#pubsub_item{}]) -> [ps_item()].
|
-spec itemsEls([#pubsub_item{}]) -> [ps_item()].
|
||||||
itemsEls(Items) ->
|
itemsEls(Items) ->
|
||||||
|
|
|
@ -392,7 +392,7 @@ send_registration_notifications(Mod, UJID, Source) ->
|
||||||
[] -> ok;
|
[] -> ok;
|
||||||
JIDs when is_list(JIDs) ->
|
JIDs when is_list(JIDs) ->
|
||||||
Body =
|
Body =
|
||||||
iolist_to_binary(io_lib:format("[~s] The account ~s was registered from "
|
(str:format("[~s] The account ~s was registered from "
|
||||||
"IP address ~s on node ~w using ~p.",
|
"IP address ~s on node ~w using ~p.",
|
||||||
[get_time_string(),
|
[get_time_string(),
|
||||||
jid:to_string(UJID),
|
jid:to_string(UJID),
|
||||||
|
|
|
@ -299,7 +299,7 @@ add_record_route_and_set_uri(URI, LServer, #sip{hdrs = Hdrs} = Req) ->
|
||||||
case need_record_route(LServer) of
|
case need_record_route(LServer) of
|
||||||
true ->
|
true ->
|
||||||
RR_URI = get_configured_record_route(LServer),
|
RR_URI = get_configured_record_route(LServer),
|
||||||
TS = list_to_binary(integer_to_list(p1_time_compat:system_time(seconds))),
|
TS = (integer_to_binary(p1_time_compat:system_time(seconds))),
|
||||||
Sign = make_sign(TS, Hdrs),
|
Sign = make_sign(TS, Hdrs),
|
||||||
User = <<TS/binary, $-, Sign/binary>>,
|
User = <<TS/binary, $-, Sign/binary>>,
|
||||||
NewRR_URI = RR_URI#uri{user = User},
|
NewRR_URI = RR_URI#uri{user = User},
|
||||||
|
@ -339,7 +339,7 @@ make_sign(TS, Hdrs) ->
|
||||||
is_signed_by_me(TS_Sign, Hdrs) ->
|
is_signed_by_me(TS_Sign, Hdrs) ->
|
||||||
try
|
try
|
||||||
[TSBin, Sign] = str:tokens(TS_Sign, <<"-">>),
|
[TSBin, Sign] = str:tokens(TS_Sign, <<"-">>),
|
||||||
TS = list_to_integer(binary_to_list(TSBin)),
|
TS = (binary_to_integer(TSBin)),
|
||||||
NowTS = p1_time_compat:system_time(seconds),
|
NowTS = p1_time_compat:system_time(seconds),
|
||||||
true = (NowTS - TS) =< ?SIGN_LIFETIME,
|
true = (NowTS - TS) =< ?SIGN_LIFETIME,
|
||||||
Sign == make_sign(TSBin, Hdrs)
|
Sign == make_sign(TSBin, Hdrs)
|
||||||
|
|
|
@ -355,7 +355,7 @@ min_expires() ->
|
||||||
60.
|
60.
|
||||||
|
|
||||||
to_integer(Bin, Min, Max) ->
|
to_integer(Bin, Min, Max) ->
|
||||||
case catch list_to_integer(binary_to_list(Bin)) of
|
case catch (binary_to_integer(Bin)) of
|
||||||
N when N >= Min, N =< Max ->
|
N when N >= Min, N =< Max ->
|
||||||
{ok, N};
|
{ok, N};
|
||||||
_ ->
|
_ ->
|
||||||
|
|
|
@ -111,7 +111,7 @@ get_local_stat(Server, [], Name)
|
||||||
{'EXIT', _Reason} ->
|
{'EXIT', _Reason} ->
|
||||||
?STATERR(500, <<"Internal Server Error">>);
|
?STATERR(500, <<"Internal Server Error">>);
|
||||||
Users ->
|
Users ->
|
||||||
?STATVAL((iolist_to_binary(integer_to_list(length(Users)))),
|
?STATVAL((integer_to_binary(length(Users))),
|
||||||
<<"users">>)
|
<<"users">>)
|
||||||
end;
|
end;
|
||||||
get_local_stat(Server, [], Name)
|
get_local_stat(Server, [], Name)
|
||||||
|
@ -122,13 +122,13 @@ get_local_stat(Server, [], Name)
|
||||||
{'EXIT', _Reason} ->
|
{'EXIT', _Reason} ->
|
||||||
?STATERR(500, <<"Internal Server Error">>);
|
?STATERR(500, <<"Internal Server Error">>);
|
||||||
NUsers ->
|
NUsers ->
|
||||||
?STATVAL((iolist_to_binary(integer_to_list(NUsers))),
|
?STATVAL((integer_to_binary(NUsers)),
|
||||||
<<"users">>)
|
<<"users">>)
|
||||||
end;
|
end;
|
||||||
get_local_stat(_Server, [], Name)
|
get_local_stat(_Server, [], Name)
|
||||||
when Name == <<"users/all-hosts/online">> ->
|
when Name == <<"users/all-hosts/online">> ->
|
||||||
Users = ejabberd_sm:connected_users_number(),
|
Users = ejabberd_sm:connected_users_number(),
|
||||||
?STATVAL((iolist_to_binary(integer_to_list(Users))), <<"users">>);
|
?STATVAL((integer_to_binary(Users)), <<"users">>);
|
||||||
get_local_stat(_Server, [], Name)
|
get_local_stat(_Server, [], Name)
|
||||||
when Name == <<"users/all-hosts/total">> ->
|
when Name == <<"users/all-hosts/total">> ->
|
||||||
NumUsers = lists:foldl(fun (Host, Total) ->
|
NumUsers = lists:foldl(fun (Host, Total) ->
|
||||||
|
@ -136,7 +136,7 @@ get_local_stat(_Server, [], Name)
|
||||||
+ Total
|
+ Total
|
||||||
end,
|
end,
|
||||||
0, ?MYHOSTS),
|
0, ?MYHOSTS),
|
||||||
?STATVAL((iolist_to_binary(integer_to_list(NumUsers))),
|
?STATVAL((integer_to_binary(NumUsers)),
|
||||||
<<"users">>);
|
<<"users">>);
|
||||||
get_local_stat(_Server, _, Name) ->
|
get_local_stat(_Server, _, Name) ->
|
||||||
?STATERR(404, <<"Not Found">>).
|
?STATERR(404, <<"Not Found">>).
|
||||||
|
@ -149,9 +149,7 @@ get_node_stat(Node, Name)
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
?STATERR(500, <<"Internal Server Error">>);
|
?STATERR(500, <<"Internal Server Error">>);
|
||||||
CPUTime ->
|
CPUTime ->
|
||||||
?STATVAL(list_to_binary(
|
?STATVAL(str:format("~.3f", [element(1, CPUTime) / 1000]),
|
||||||
io_lib:format("~.3f",
|
|
||||||
[element(1, CPUTime) / 1000])),
|
|
||||||
<<"seconds">>)
|
<<"seconds">>)
|
||||||
end;
|
end;
|
||||||
get_node_stat(Node, Name)
|
get_node_stat(Node, Name)
|
||||||
|
@ -161,9 +159,7 @@ get_node_stat(Node, Name)
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
?STATERR(500, <<"Internal Server Error">>);
|
?STATERR(500, <<"Internal Server Error">>);
|
||||||
RunTime ->
|
RunTime ->
|
||||||
?STATVAL(list_to_binary(
|
?STATVAL(str:format("~.3f", [element(1, RunTime) / 1000]),
|
||||||
io_lib:format("~.3f",
|
|
||||||
[element(1, RunTime) / 1000])),
|
|
||||||
<<"seconds">>)
|
<<"seconds">>)
|
||||||
end;
|
end;
|
||||||
get_node_stat(Node, Name)
|
get_node_stat(Node, Name)
|
||||||
|
@ -174,7 +170,7 @@ get_node_stat(Node, Name)
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
?STATERR(500, <<"Internal Server Error">>);
|
?STATERR(500, <<"Internal Server Error">>);
|
||||||
Users ->
|
Users ->
|
||||||
?STATVAL((iolist_to_binary(integer_to_list(length(Users)))),
|
?STATVAL((integer_to_binary(length(Users))),
|
||||||
<<"users">>)
|
<<"users">>)
|
||||||
end;
|
end;
|
||||||
get_node_stat(Node, Name)
|
get_node_stat(Node, Name)
|
||||||
|
@ -185,7 +181,7 @@ get_node_stat(Node, Name)
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
?STATERR(500, <<"Internal Server Error">>);
|
?STATERR(500, <<"Internal Server Error">>);
|
||||||
Transactions ->
|
Transactions ->
|
||||||
?STATVAL((iolist_to_binary(integer_to_list(Transactions))),
|
?STATVAL((integer_to_binary(Transactions)),
|
||||||
<<"transactions">>)
|
<<"transactions">>)
|
||||||
end;
|
end;
|
||||||
get_node_stat(Node, Name)
|
get_node_stat(Node, Name)
|
||||||
|
@ -196,7 +192,7 @@ get_node_stat(Node, Name)
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
?STATERR(500, <<"Internal Server Error">>);
|
?STATERR(500, <<"Internal Server Error">>);
|
||||||
Transactions ->
|
Transactions ->
|
||||||
?STATVAL((iolist_to_binary(integer_to_list(Transactions))),
|
?STATVAL((integer_to_binary(Transactions)),
|
||||||
<<"transactions">>)
|
<<"transactions">>)
|
||||||
end;
|
end;
|
||||||
get_node_stat(Node, Name)
|
get_node_stat(Node, Name)
|
||||||
|
@ -207,7 +203,7 @@ get_node_stat(Node, Name)
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
?STATERR(500, <<"Internal Server Error">>);
|
?STATERR(500, <<"Internal Server Error">>);
|
||||||
Transactions ->
|
Transactions ->
|
||||||
?STATVAL((iolist_to_binary(integer_to_list(Transactions))),
|
?STATVAL((integer_to_binary(Transactions)),
|
||||||
<<"transactions">>)
|
<<"transactions">>)
|
||||||
end;
|
end;
|
||||||
get_node_stat(Node, Name)
|
get_node_stat(Node, Name)
|
||||||
|
@ -218,7 +214,7 @@ get_node_stat(Node, Name)
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
?STATERR(500, <<"Internal Server Error">>);
|
?STATERR(500, <<"Internal Server Error">>);
|
||||||
Transactions ->
|
Transactions ->
|
||||||
?STATVAL((iolist_to_binary(integer_to_list(Transactions))),
|
?STATVAL((integer_to_binary(Transactions)),
|
||||||
<<"transactions">>)
|
<<"transactions">>)
|
||||||
end;
|
end;
|
||||||
get_node_stat(_, Name) ->
|
get_node_stat(_, Name) ->
|
||||||
|
|
|
@ -70,7 +70,7 @@ get_os() ->
|
||||||
OSType = list_to_binary([atom_to_list(Osfamily), $/, atom_to_list(Osname)]),
|
OSType = list_to_binary([atom_to_list(Osfamily), $/, atom_to_list(Osname)]),
|
||||||
OSVersion = case os:version() of
|
OSVersion = case os:version() of
|
||||||
{Major, Minor, Release} ->
|
{Major, Minor, Release} ->
|
||||||
iolist_to_binary(io_lib:format("~w.~w.~w",
|
(str:format("~w.~w.~w",
|
||||||
[Major, Minor, Release]));
|
[Major, Minor, Release]));
|
||||||
VersionString -> VersionString
|
VersionString -> VersionString
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -127,7 +127,7 @@ subscription_opt_to_sql({subscription_depth, Depth}) ->
|
||||||
N -> integer_to_sql(N)
|
N -> integer_to_sql(N)
|
||||||
end}.
|
end}.
|
||||||
|
|
||||||
integer_to_sql(N) -> iolist_to_binary(integer_to_list(N)).
|
integer_to_sql(N) -> integer_to_binary(N).
|
||||||
|
|
||||||
boolean_to_sql(true) -> <<"1">>;
|
boolean_to_sql(true) -> <<"1">>;
|
||||||
boolean_to_sql(false) -> <<"0">>.
|
boolean_to_sql(false) -> <<"0">>.
|
||||||
|
|
|
@ -170,7 +170,7 @@ write_subscription(_JID, _NodeId, SubID, Options) ->
|
||||||
-spec make_subid() -> SubId::mod_pubsub:subId().
|
-spec make_subid() -> SubId::mod_pubsub:subId().
|
||||||
make_subid() ->
|
make_subid() ->
|
||||||
{T1, T2, T3} = p1_time_compat:timestamp(),
|
{T1, T2, T3} = p1_time_compat:timestamp(),
|
||||||
iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])).
|
(str:format("~.16B~.16B~.16B", [T1, T2, T3])).
|
||||||
|
|
||||||
%%
|
%%
|
||||||
%% Subscription XForm processing.
|
%% Subscription XForm processing.
|
||||||
|
@ -207,14 +207,14 @@ val_xfield(digest_frequency = Opt, [Val]) ->
|
||||||
N when is_integer(N) -> N;
|
N when is_integer(N) -> N;
|
||||||
_ ->
|
_ ->
|
||||||
Txt = <<"Value of '~s' should be integer">>,
|
Txt = <<"Value of '~s' should be integer">>,
|
||||||
ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
|
ErrTxt = (str:format(Txt, [Opt])),
|
||||||
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
|
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
|
||||||
end;
|
end;
|
||||||
val_xfield(expire = Opt, [Val]) ->
|
val_xfield(expire = Opt, [Val]) ->
|
||||||
try xmpp_util:decode_timestamp(Val)
|
try xmpp_util:decode_timestamp(Val)
|
||||||
catch _:{bad_timestamp, _} ->
|
catch _:{bad_timestamp, _} ->
|
||||||
Txt = <<"Value of '~s' should be datetime string">>,
|
Txt = <<"Value of '~s' should be datetime string">>,
|
||||||
ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
|
ErrTxt = (str:format(Txt, [Opt])),
|
||||||
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
|
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
|
||||||
end;
|
end;
|
||||||
val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val);
|
val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val);
|
||||||
|
@ -227,7 +227,7 @@ val_xfield(subscription_depth = Opt, [Depth]) ->
|
||||||
N when is_integer(N) -> N;
|
N when is_integer(N) -> N;
|
||||||
_ ->
|
_ ->
|
||||||
Txt = <<"Value of '~s' should be integer">>,
|
Txt = <<"Value of '~s' should be integer">>,
|
||||||
ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
|
ErrTxt = (str:format(Txt, [Opt])),
|
||||||
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
|
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ xopt_to_bool(_, <<"false">>) -> false;
|
||||||
xopt_to_bool(_, <<"true">>) -> true;
|
xopt_to_bool(_, <<"true">>) -> true;
|
||||||
xopt_to_bool(Option, _) ->
|
xopt_to_bool(Option, _) ->
|
||||||
Txt = <<"Value of '~s' should be boolean">>,
|
Txt = <<"Value of '~s' should be boolean">>,
|
||||||
ErrTxt = iolist_to_binary(io_lib:format(Txt, [Option])),
|
ErrTxt = (str:format(Txt, [Option])),
|
||||||
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}.
|
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}.
|
||||||
|
|
||||||
%% Return a field for an XForm for Key, with data filled in, if
|
%% Return a field for an XForm for Key, with data filled in, if
|
||||||
|
@ -311,7 +311,7 @@ xfield_label(subscription_depth) -> ?SUBSCRIPTION_DEPTH_LABEL.
|
||||||
xfield_val(deliver, Val) -> [bool_to_xopt(Val)];
|
xfield_val(deliver, Val) -> [bool_to_xopt(Val)];
|
||||||
%xfield_val(digest, Val) -> [bool_to_xopt(Val)];
|
%xfield_val(digest, Val) -> [bool_to_xopt(Val)];
|
||||||
%xfield_val(digest_frequency, Val) ->
|
%xfield_val(digest_frequency, Val) ->
|
||||||
% [iolist_to_binary(integer_to_list(Val))];
|
% [integer_to_binary(Val))];
|
||||||
%xfield_val(expire, Val) ->
|
%xfield_val(expire, Val) ->
|
||||||
% [jlib:now_to_utc_string(Val)];
|
% [jlib:now_to_utc_string(Val)];
|
||||||
%xfield_val(include_body, Val) -> [bool_to_xopt(Val)];
|
%xfield_val(include_body, Val) -> [bool_to_xopt(Val)];
|
||||||
|
@ -320,7 +320,7 @@ xfield_val(subscription_type, items) -> [<<"items">>];
|
||||||
xfield_val(subscription_type, nodes) -> [<<"nodes">>];
|
xfield_val(subscription_type, nodes) -> [<<"nodes">>];
|
||||||
xfield_val(subscription_depth, all) -> [<<"all">>];
|
xfield_val(subscription_depth, all) -> [<<"all">>];
|
||||||
xfield_val(subscription_depth, N) ->
|
xfield_val(subscription_depth, N) ->
|
||||||
[iolist_to_binary(integer_to_list(N))].
|
[integer_to_binary(N)].
|
||||||
|
|
||||||
|
|
||||||
bool_to_xopt(true) -> <<"true">>;
|
bool_to_xopt(true) -> <<"true">>;
|
||||||
|
|
|
@ -135,7 +135,7 @@ create_table() -> ok.
|
||||||
-spec make_subid() -> mod_pubsub:subId().
|
-spec make_subid() -> mod_pubsub:subId().
|
||||||
make_subid() ->
|
make_subid() ->
|
||||||
{T1, T2, T3} = p1_time_compat:timestamp(),
|
{T1, T2, T3} = p1_time_compat:timestamp(),
|
||||||
iolist_to_binary(io_lib:fwrite("~.16B~.16B~.16B", [T1, T2, T3])).
|
(str:format("~.16B~.16B~.16B", [T1, T2, T3])).
|
||||||
|
|
||||||
%%
|
%%
|
||||||
%% Subscription XForm processing.
|
%% Subscription XForm processing.
|
||||||
|
@ -172,14 +172,14 @@ val_xfield(digest_frequency = Opt, [Val]) ->
|
||||||
N when is_integer(N) -> N;
|
N when is_integer(N) -> N;
|
||||||
_ ->
|
_ ->
|
||||||
Txt = <<"Value of '~s' should be integer">>,
|
Txt = <<"Value of '~s' should be integer">>,
|
||||||
ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
|
ErrTxt = (str:format(Txt, [Opt])),
|
||||||
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
|
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
|
||||||
end;
|
end;
|
||||||
val_xfield(expire = Opt, [Val]) ->
|
val_xfield(expire = Opt, [Val]) ->
|
||||||
try xmpp_util:decode_timestamp(Val)
|
try xmpp_util:decode_timestamp(Val)
|
||||||
catch _:{bad_timestamp, _} ->
|
catch _:{bad_timestamp, _} ->
|
||||||
Txt = <<"Value of '~s' should be datetime string">>,
|
Txt = <<"Value of '~s' should be datetime string">>,
|
||||||
ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
|
ErrTxt = (str:format(Txt, [Opt])),
|
||||||
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
|
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
|
||||||
end;
|
end;
|
||||||
val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val);
|
val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val);
|
||||||
|
@ -192,7 +192,7 @@ val_xfield(subscription_depth = Opt, [Depth]) ->
|
||||||
N when is_integer(N) -> N;
|
N when is_integer(N) -> N;
|
||||||
_ ->
|
_ ->
|
||||||
Txt = <<"Value of '~s' should be integer">>,
|
Txt = <<"Value of '~s' should be integer">>,
|
||||||
ErrTxt = iolist_to_binary(io_lib:format(Txt, [Opt])),
|
ErrTxt = (str:format(Txt, [Opt])),
|
||||||
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
|
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ xopt_to_bool(_, <<"false">>) -> false;
|
||||||
xopt_to_bool(_, <<"true">>) -> true;
|
xopt_to_bool(_, <<"true">>) -> true;
|
||||||
xopt_to_bool(Option, _) ->
|
xopt_to_bool(Option, _) ->
|
||||||
Txt = <<"Value of '~s' should be boolean">>,
|
Txt = <<"Value of '~s' should be boolean">>,
|
||||||
ErrTxt = iolist_to_binary(io_lib:format(Txt, [Option])),
|
ErrTxt = (str:format(Txt, [Option])),
|
||||||
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}.
|
{error, xmpp:err_not_acceptable(ErrTxt, ?MYLANG)}.
|
||||||
|
|
||||||
%% Return a field for an XForm for Key, with data filled in, if
|
%% Return a field for an XForm for Key, with data filled in, if
|
||||||
|
@ -276,7 +276,7 @@ xfield_label(subscription_depth) -> ?SUBSCRIPTION_DEPTH_LABEL.
|
||||||
xfield_val(deliver, Val) -> [bool_to_xopt(Val)];
|
xfield_val(deliver, Val) -> [bool_to_xopt(Val)];
|
||||||
%xfield_val(digest, Val) -> [bool_to_xopt(Val)];
|
%xfield_val(digest, Val) -> [bool_to_xopt(Val)];
|
||||||
%xfield_val(digest_frequency, Val) ->
|
%xfield_val(digest_frequency, Val) ->
|
||||||
% [iolist_to_binary(integer_to_list(Val))];
|
% [integer_to_binary(Val))];
|
||||||
%xfield_val(expire, Val) ->
|
%xfield_val(expire, Val) ->
|
||||||
% [jlib:now_to_utc_string(Val)];
|
% [jlib:now_to_utc_string(Val)];
|
||||||
%xfield_val(include_body, Val) -> [bool_to_xopt(Val)];
|
%xfield_val(include_body, Val) -> [bool_to_xopt(Val)];
|
||||||
|
@ -285,7 +285,7 @@ xfield_val(subscription_type, items) -> [<<"items">>];
|
||||||
xfield_val(subscription_type, nodes) -> [<<"nodes">>];
|
xfield_val(subscription_type, nodes) -> [<<"nodes">>];
|
||||||
xfield_val(subscription_depth, all) -> [<<"all">>];
|
xfield_val(subscription_depth, all) -> [<<"all">>];
|
||||||
xfield_val(subscription_depth, N) ->
|
xfield_val(subscription_depth, N) ->
|
||||||
[iolist_to_binary(integer_to_list(N))].
|
[integer_to_binary(N)].
|
||||||
|
|
||||||
bool_to_xopt(false) -> <<"false">>;
|
bool_to_xopt(false) -> <<"false">>;
|
||||||
bool_to_xopt(true) -> <<"true">>.
|
bool_to_xopt(true) -> <<"true">>.
|
||||||
|
|
Loading…
Reference in New Issue