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

Move JID related functions to jid.erl (#847)

This commit is contained in:
Evgeniy Khramtsov 2015-11-24 18:44:13 +03:00
parent 7eddfe073b
commit 95265dd3ad
81 changed files with 1189 additions and 1072 deletions

View File

@ -208,13 +208,13 @@ b(S) ->
iolist_to_binary(S). iolist_to_binary(S).
nodeprep(S) -> nodeprep(S) ->
jlib:nodeprep(b(S)). jid:nodeprep(b(S)).
nameprep(S) -> nameprep(S) ->
jlib:nameprep(b(S)). jid:nameprep(b(S)).
resourceprep(S) -> resourceprep(S) ->
jlib:resourceprep(b(S)). jid:resourceprep(b(S)).
normalize_spec(Spec) -> normalize_spec(Spec) ->
case Spec of case Spec of
@ -295,7 +295,7 @@ match_acl(ACL, IP, Host) when tuple_size(IP) == 4;
false false
end, get_aclspecs(ACL, Host)); end, get_aclspecs(ACL, Host));
match_acl(ACL, JID, Host) -> match_acl(ACL, JID, Host) ->
{User, Server, Resource} = jlib:jid_tolower(JID), {User, Server, Resource} = jid:tolower(JID),
lists:any( lists:any(
fun(#acl{aclspec = Spec}) -> fun(#acl{aclspec = Spec}) ->
case Spec of case Spec of

View File

@ -112,12 +112,12 @@ register_mechanism(Mechanism, Module, PasswordType) ->
%%-include("jlib.hrl"). %%-include("jlib.hrl").
%%check_authzid(_State, Props) -> %%check_authzid(_State, Props) ->
%% AuthzId = xml:get_attr_s(authzid, Props), %% AuthzId = xml:get_attr_s(authzid, Props),
%% case jlib:string_to_jid(AuthzId) of %% case jid:from_string(AuthzId) of
%% error -> %% error ->
%% {error, "invalid-authzid"}; %% {error, "invalid-authzid"};
%% JID -> %% JID ->
%% LUser = jlib:nodeprep(xml:get_attr_s(username, Props)), %% LUser = jid:nodeprep(xml:get_attr_s(username, Props)),
%% {U, S, R} = jlib:jid_tolower(JID), %% {U, S, R} = jid:tolower(JID),
%% case R of %% case R of
%% "" -> %% "" ->
%% {error, "invalid-authzid"}; %% {error, "invalid-authzid"};
@ -133,7 +133,7 @@ register_mechanism(Mechanism, Module, PasswordType) ->
check_credentials(_State, Props) -> check_credentials(_State, Props) ->
User = proplists:get_value(username, Props, <<>>), User = proplists:get_value(username, Props, <<>>),
case jlib:nodeprep(User) of case jid:nodeprep(User) of
error -> {error, <<"not-authorized">>}; error -> {error, <<"not-authorized">>};
<<"">> -> {error, <<"not-authorized">>}; <<"">> -> {error, <<"not-authorized">>};
_LUser -> ok _LUser -> ok

View File

@ -79,7 +79,7 @@ mech_step(#state{step = 2} = State, ClientIn) ->
case parse_attribute(ClientNonceAttribute) of case parse_attribute(ClientNonceAttribute) of
{$r, ClientNonce} -> {$r, ClientNonce} ->
{Ret, _AuthModule} = (State#state.get_password)(UserName), {Ret, _AuthModule} = (State#state.get_password)(UserName),
case {Ret, jlib:resourceprep(Ret)} of case {Ret, jid:resourceprep(Ret)} of
{false, _} -> {error, <<"not-authorized">>, UserName}; {false, _} -> {error, <<"not-authorized">>, UserName};
{_, error} when is_binary(Ret) -> ?WARNING_MSG("invalid plain password", []), {error, <<"not-authorized">>, UserName}; {_, error} when is_binary(Ret) -> ?WARNING_MSG("invalid plain password", []), {error, <<"not-authorized">>, UserName};
{Ret, _} -> {Ret, _} ->

View File

@ -43,7 +43,7 @@
start(normal, _Args) -> start(normal, _Args) ->
ejabberd_logger:start(), ejabberd_logger:start(),
write_pid_file(), write_pid_file(),
jlib:start(), jid:start(),
start_apps(), start_apps(),
ejabberd:check_app(ejabberd), ejabberd:check_app(ejabberd),
randoms:start(), randoms:start(),

View File

@ -187,7 +187,7 @@ try_register(User, Server, Password) ->
case is_user_exists(User, Server) of case is_user_exists(User, Server) of
true -> {atomic, exists}; true -> {atomic, exists};
false -> false ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case lists:member(LServer, ?MYHOSTS) of case lists:member(LServer, ?MYHOSTS) of
true -> true ->
Res = lists:foldl(fun (_M, {atomic, ok} = Res) -> Res; Res = lists:foldl(fun (_M, {atomic, ok} = Res) -> Res;
@ -358,7 +358,7 @@ remove_user(User, Server) ->
lists:foreach(fun (M) -> M:remove_user(User, Server) lists:foreach(fun (M) -> M:remove_user(User, Server)
end, end,
auth_modules(Server)), auth_modules(Server)),
ejabberd_hooks:run(remove_user, jlib:nameprep(Server), ejabberd_hooks:run(remove_user, jid:nameprep(Server),
[User, Server]), [User, Server]),
ok. ok.
@ -376,7 +376,7 @@ remove_user(User, Server, Password) ->
error, auth_modules(Server)), error, auth_modules(Server)),
case R of case R of
ok -> ok ->
ejabberd_hooks:run(remove_user, jlib:nameprep(Server), ejabberd_hooks:run(remove_user, jid:nameprep(Server),
[User, Server]); [User, Server]);
_ -> none _ -> none
end, end,
@ -427,7 +427,7 @@ auth_modules() ->
%% Return the list of authenticated modules for a given host %% Return the list of authenticated modules for a given host
auth_modules(Server) -> auth_modules(Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
Default = case gen_mod:default_db(LServer) of Default = case gen_mod:default_db(LServer) of
mnesia -> internal; mnesia -> internal;
DBType -> DBType DBType -> DBType

View File

@ -122,8 +122,8 @@ allow_multiple_connections(Host) ->
%% Check if user exist in the anonymus database %% Check if user exist in the anonymus database
anonymous_user_exist(User, Server) -> anonymous_user_exist(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
case catch mnesia:dirty_read({anonymous, US}) of case catch mnesia:dirty_read({anonymous, US}) of
[] -> [] ->

View File

@ -70,7 +70,7 @@ start(Host) ->
update_reg_users_counter_table(Server) -> update_reg_users_counter_table(Server) ->
Set = get_vh_registered_users(Server), Set = get_vh_registered_users(Server),
Size = length(Set), Size = length(Set),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
F = fun () -> F = fun () ->
mnesia:write(#reg_users_counter{vhost = LServer, mnesia:write(#reg_users_counter{vhost = LServer,
count = Size}) count = Size})
@ -87,8 +87,8 @@ store_type() ->
end. end.
check_password(User, Server, Password) -> check_password(User, Server, Password) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
case catch mnesia:dirty_read({passwd, US}) of case catch mnesia:dirty_read({passwd, US}) of
[#passwd{password = Password}] [#passwd{password = Password}]
@ -102,8 +102,8 @@ check_password(User, Server, Password) ->
check_password(User, Server, Password, Digest, check_password(User, Server, Password, Digest,
DigestGen) -> DigestGen) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
case catch mnesia:dirty_read({passwd, US}) of case catch mnesia:dirty_read({passwd, US}) of
[#passwd{password = Passwd}] when is_binary(Passwd) -> [#passwd{password = Passwd}] when is_binary(Passwd) ->
@ -130,8 +130,8 @@ check_password(User, Server, Password, Digest,
%% @spec (User::string(), Server::string(), Password::string()) -> %% @spec (User::string(), Server::string(), Password::string()) ->
%% ok | {error, invalid_jid} %% ok | {error, invalid_jid}
set_password(User, Server, Password) -> set_password(User, Server, Password) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
if (LUser == error) or (LServer == error) -> if (LUser == error) or (LServer == error) ->
{error, invalid_jid}; {error, invalid_jid};
@ -150,8 +150,8 @@ set_password(User, Server, Password) ->
%% @spec (User, Server, Password) -> {atomic, ok} | {atomic, exists} | {error, invalid_jid} | {error, not_allowed} | {error, Reason} %% @spec (User, Server, Password) -> {atomic, ok} | {atomic, exists} | {error, invalid_jid} | {error, not_allowed} | {error, Reason}
try_register(User, Server, PasswordList) -> try_register(User, Server, PasswordList) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
Password = if is_list(PasswordList); is_binary(PasswordList) -> Password = if is_list(PasswordList); is_binary(PasswordList) ->
iolist_to_binary(PasswordList); iolist_to_binary(PasswordList);
true -> PasswordList true -> PasswordList
@ -185,7 +185,7 @@ dirty_get_registered_users() ->
mnesia:dirty_all_keys(passwd). mnesia:dirty_all_keys(passwd).
get_vh_registered_users(Server) -> get_vh_registered_users(Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
mnesia:dirty_select(passwd, mnesia:dirty_select(passwd,
[{#passwd{us = '$1', _ = '_'}, [{#passwd{us = '$1', _ = '_'},
[{'==', {element, 2, '$1'}, LServer}], ['$1']}]). [{'==', {element, 2, '$1'}, LServer}], ['$1']}]).
@ -244,7 +244,7 @@ get_vh_registered_users(Server, _) ->
get_vh_registered_users(Server). get_vh_registered_users(Server).
get_vh_registered_users_number(Server) -> get_vh_registered_users_number(Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
Query = mnesia:dirty_select(reg_users_counter, Query = mnesia:dirty_select(reg_users_counter,
[{#reg_users_counter{vhost = LServer, [{#reg_users_counter{vhost = LServer,
count = '$1'}, count = '$1'},
@ -265,8 +265,8 @@ get_vh_registered_users_number(Server, _) ->
get_vh_registered_users_number(Server). get_vh_registered_users_number(Server).
get_password(User, Server) -> get_password(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
case catch mnesia:dirty_read(passwd, US) of case catch mnesia:dirty_read(passwd, US) of
[#passwd{password = Password}] [#passwd{password = Password}]
@ -282,8 +282,8 @@ get_password(User, Server) ->
end. end.
get_password_s(User, Server) -> get_password_s(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
case catch mnesia:dirty_read(passwd, US) of case catch mnesia:dirty_read(passwd, US) of
[#passwd{password = Password}] [#passwd{password = Password}]
@ -297,8 +297,8 @@ get_password_s(User, Server) ->
%% @spec (User, Server) -> true | false | {error, Error} %% @spec (User, Server) -> true | false | {error, Error}
is_user_exists(User, Server) -> is_user_exists(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
case catch mnesia:dirty_read({passwd, US}) of case catch mnesia:dirty_read({passwd, US}) of
[] -> false; [] -> false;
@ -310,8 +310,8 @@ is_user_exists(User, Server) ->
%% @doc Remove user. %% @doc Remove user.
%% Note: it returns ok even if there was some problem removing the user. %% Note: it returns ok even if there was some problem removing the user.
remove_user(User, Server) -> remove_user(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
F = fun () -> F = fun () ->
mnesia:delete({passwd, US}), mnesia:delete({passwd, US}),
@ -324,8 +324,8 @@ remove_user(User, Server) ->
%% @spec (User, Server, Password) -> ok | not_exists | not_allowed | bad_request %% @spec (User, Server, Password) -> ok | not_exists | not_allowed | bad_request
%% @doc Remove user if the provided password is correct. %% @doc Remove user if the provided password is correct.
remove_user(User, Server, Password) -> remove_user(User, Server, Password) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
F = fun () -> F = fun () ->
case mnesia:read({passwd, US}) of case mnesia:read({passwd, US}) of

View File

@ -228,11 +228,11 @@ get_vh_registered_users_ldap(Server) ->
UIDFormat) UIDFormat)
of of
{ok, U} -> {ok, U} ->
case jlib:nodeprep(U) of case jid:nodeprep(U) of
error -> []; error -> [];
LU -> LU ->
[{LU, [{LU,
jlib:nameprep(Server)}] jid:nameprep(Server)}]
end; end;
_ -> [] _ -> []
end end

View File

@ -65,8 +65,8 @@ store_type() ->
%% @spec (User, Server, Password) -> true | false | {error, Error} %% @spec (User, Server, Password) -> true | false | {error, Error}
check_password(User, Server, Password) -> check_password(User, Server, Password) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
if (LUser == error) or (LServer == error) -> if (LUser == error) or (LServer == error) ->
false; false;
(LUser == <<>>) or (LServer == <<>>) -> (LUser == <<>>) or (LServer == <<>>) ->
@ -115,8 +115,8 @@ check_password(User, Server, Password) ->
%% @spec (User, Server, Password, Digest, DigestGen) -> true | false | {error, Error} %% @spec (User, Server, Password, Digest, DigestGen) -> true | false | {error, Error}
check_password(User, Server, Password, Digest, check_password(User, Server, Password, Digest,
DigestGen) -> DigestGen) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
if (LUser == error) or (LServer == error) -> if (LUser == error) or (LServer == error) ->
false; false;
(LUser == <<>>) or (LServer == <<>>) -> (LUser == <<>>) or (LServer == <<>>) ->
@ -151,8 +151,8 @@ check_password(User, Server, Password, Digest,
%% @spec (User::string(), Server::string(), Password::string()) -> %% @spec (User::string(), Server::string(), Password::string()) ->
%% ok | {error, invalid_jid} %% ok | {error, invalid_jid}
set_password(User, Server, Password) -> set_password(User, Server, Password) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
if (LUser == error) or (LServer == error) -> if (LUser == error) or (LServer == error) ->
{error, invalid_jid}; {error, invalid_jid};
(LUser == <<>>) or (LServer == <<>>) -> (LUser == <<>>) or (LServer == <<>>) ->
@ -187,8 +187,8 @@ set_password(User, Server, Password) ->
%% @spec (User, Server, Password) -> {atomic, ok} | {atomic, exists} | {error, invalid_jid} %% @spec (User, Server, Password) -> {atomic, ok} | {atomic, exists} | {error, invalid_jid}
try_register(User, Server, Password) -> try_register(User, Server, Password) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
if (LUser == error) or (LServer == error) -> if (LUser == error) or (LServer == error) ->
{error, invalid_jid}; {error, invalid_jid};
(LUser == <<>>) or (LServer == <<>>) -> (LUser == <<>>) or (LServer == <<>>) ->
@ -228,7 +228,7 @@ dirty_get_registered_users() ->
Servers). Servers).
get_vh_registered_users(Server) -> get_vh_registered_users(Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case catch odbc_queries:list_users(LServer) of case catch odbc_queries:list_users(LServer) of
{selected, [<<"username">>], Res} -> {selected, [<<"username">>], Res} ->
[{U, LServer} || [U] <- Res]; [{U, LServer} || [U] <- Res];
@ -236,7 +236,7 @@ get_vh_registered_users(Server) ->
end. end.
get_vh_registered_users(Server, Opts) -> get_vh_registered_users(Server, Opts) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case catch odbc_queries:list_users(LServer, Opts) of case catch odbc_queries:list_users(LServer, Opts) of
{selected, [<<"username">>], Res} -> {selected, [<<"username">>], Res} ->
[{U, LServer} || [U] <- Res]; [{U, LServer} || [U] <- Res];
@ -244,7 +244,7 @@ get_vh_registered_users(Server, Opts) ->
end. end.
get_vh_registered_users_number(Server) -> get_vh_registered_users_number(Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case catch odbc_queries:users_number(LServer) of case catch odbc_queries:users_number(LServer) of
{selected, [_], [[Res]]} -> {selected, [_], [[Res]]} ->
jlib:binary_to_integer(Res); jlib:binary_to_integer(Res);
@ -252,7 +252,7 @@ get_vh_registered_users_number(Server) ->
end. end.
get_vh_registered_users_number(Server, Opts) -> get_vh_registered_users_number(Server, Opts) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case catch odbc_queries:users_number(LServer, Opts) of case catch odbc_queries:users_number(LServer, Opts) of
{selected, [_], [[Res]]} -> {selected, [_], [[Res]]} ->
jlib:binary_to_integer(Res); jlib:binary_to_integer(Res);
@ -260,8 +260,8 @@ get_vh_registered_users_number(Server, Opts) ->
end. end.
get_password(User, Server) -> get_password(User, Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
if (LUser == error) or (LServer == error) -> if (LUser == error) or (LServer == error) ->
false; false;
(LUser == <<>>) or (LServer == <<>>) -> (LUser == <<>>) or (LServer == <<>>) ->
@ -291,8 +291,8 @@ get_password(User, Server) ->
end. end.
get_password_s(User, Server) -> get_password_s(User, Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
if (LUser == error) or (LServer == error) -> if (LUser == error) or (LServer == error) ->
<<"">>; <<"">>;
(LUser == <<>>) or (LServer == <<>>) -> (LUser == <<>>) or (LServer == <<>>) ->
@ -311,11 +311,11 @@ get_password_s(User, Server) ->
%% @spec (User, Server) -> true | false | {error, Error} %% @spec (User, Server) -> true | false | {error, Error}
is_user_exists(User, Server) -> is_user_exists(User, Server) ->
case jlib:nodeprep(User) of case jid:nodeprep(User) of
error -> false; error -> false;
LUser -> LUser ->
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
try odbc_queries:get_password(LServer, Username) of try odbc_queries:get_password(LServer, Username) of
{selected, [<<"password">>], [[_Password]]} -> {selected, [<<"password">>], [[_Password]]} ->
true; %% Account exists true; %% Account exists
@ -331,11 +331,11 @@ is_user_exists(User, Server) ->
%% @doc Remove user. %% @doc Remove user.
%% Note: it may return ok even if there was some problem removing the user. %% Note: it may return ok even if there was some problem removing the user.
remove_user(User, Server) -> remove_user(User, Server) ->
case jlib:nodeprep(User) of case jid:nodeprep(User) of
error -> error; error -> error;
LUser -> LUser ->
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
catch odbc_queries:del_user(LServer, Username), catch odbc_queries:del_user(LServer, Username),
ok ok
end. end.
@ -343,8 +343,8 @@ remove_user(User, Server) ->
%% @spec (User, Server, Password) -> ok | error | not_exists | not_allowed %% @spec (User, Server, Password) -> ok | error | not_exists | not_allowed
%% @doc Remove user if the provided password is correct. %% @doc Remove user if the provided password is correct.
remove_user(User, Server, Password) -> remove_user(User, Server, Password) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
if (LUser == error) or (LServer == error) -> if (LUser == error) or (LServer == error) ->
error; error;
(LUser == <<>>) or (LServer == <<>>) -> (LUser == <<>>) or (LServer == <<>>) ->
@ -429,7 +429,7 @@ set_password_scram_t(Username,
<<"'">>]). <<"'">>]).
convert_to_scram(Server) -> convert_to_scram(Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
if if
LServer == error; LServer == error;
LServer == <<>> -> LServer == <<>> ->

View File

@ -67,8 +67,8 @@ passwd_schema() ->
{record_info(fields, passwd), #passwd{}}. {record_info(fields, passwd), #passwd{}}.
check_password(User, Server, Password) -> check_password(User, Server, Password) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of
{ok, #passwd{password = Password}} when is_binary(Password) -> {ok, #passwd{password = Password}} when is_binary(Password) ->
Password /= <<"">>; Password /= <<"">>;
@ -80,8 +80,8 @@ check_password(User, Server, Password) ->
check_password(User, Server, Password, Digest, check_password(User, Server, Password, Digest,
DigestGen) -> DigestGen) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of
{ok, #passwd{password = Passwd}} when is_binary(Passwd) -> {ok, #passwd{password = Passwd}} when is_binary(Passwd) ->
DigRes = if Digest /= <<"">> -> DigRes = if Digest /= <<"">> ->
@ -105,8 +105,8 @@ check_password(User, Server, Password, Digest,
end. end.
set_password(User, Server, Password) -> set_password(User, Server, Password) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
if (LUser == error) or (LServer == error) -> if (LUser == error) or (LServer == error) ->
{error, invalid_jid}; {error, invalid_jid};
@ -122,8 +122,8 @@ set_password(User, Server, Password) ->
end. end.
try_register(User, Server, PasswordList) -> try_register(User, Server, PasswordList) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
Password = if is_list(PasswordList); is_binary(PasswordList) -> Password = if is_list(PasswordList); is_binary(PasswordList) ->
iolist_to_binary(PasswordList); iolist_to_binary(PasswordList);
true -> PasswordList true -> PasswordList
@ -159,7 +159,7 @@ dirty_get_registered_users() ->
end, ejabberd_config:get_vh_by_auth_method(riak)). end, ejabberd_config:get_vh_by_auth_method(riak)).
get_vh_registered_users(Server) -> get_vh_registered_users(Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case ejabberd_riak:get_keys_by_index(passwd, <<"host">>, LServer) of case ejabberd_riak:get_keys_by_index(passwd, <<"host">>, LServer) of
{ok, Users} -> {ok, Users} ->
Users; Users;
@ -171,7 +171,7 @@ get_vh_registered_users(Server, _) ->
get_vh_registered_users(Server). get_vh_registered_users(Server).
get_vh_registered_users_number(Server) -> get_vh_registered_users_number(Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case ejabberd_riak:count_by_index(passwd, <<"host">>, LServer) of case ejabberd_riak:count_by_index(passwd, <<"host">>, LServer) of
{ok, N} -> {ok, N} ->
N; N;
@ -183,8 +183,8 @@ get_vh_registered_users_number(Server, _) ->
get_vh_registered_users_number(Server). get_vh_registered_users_number(Server).
get_password(User, Server) -> get_password(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of
{ok, #passwd{password = Password}} {ok, #passwd{password = Password}}
when is_binary(Password) -> when is_binary(Password) ->
@ -199,8 +199,8 @@ get_password(User, Server) ->
end. end.
get_password_s(User, Server) -> get_password_s(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of
{ok, #passwd{password = Password}} {ok, #passwd{password = Password}}
when is_binary(Password) -> when is_binary(Password) ->
@ -212,8 +212,8 @@ get_password_s(User, Server) ->
end. end.
is_user_exists(User, Server) -> is_user_exists(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of
{error, notfound} -> false; {error, notfound} -> false;
{ok, _} -> true; {ok, _} -> true;
@ -221,14 +221,14 @@ is_user_exists(User, Server) ->
end. end.
remove_user(User, Server) -> remove_user(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
ejabberd_riak:delete(passwd, {LUser, LServer}), ejabberd_riak:delete(passwd, {LUser, LServer}),
ok. ok.
remove_user(User, Server, Password) -> remove_user(User, Server, Password) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of case ejabberd_riak:get(passwd, passwd_schema(), {LUser, LServer}) of
{ok, #passwd{password = Password}} {ok, #passwd{password = Password}}
when is_binary(Password) -> when is_binary(Password) ->

View File

@ -224,7 +224,7 @@ del_aux_field(Key, #state{aux_fields = Opts} = State) ->
State#state{aux_fields = Opts1}. State#state{aux_fields = Opts1}.
get_subscription(From = #jid{}, StateData) -> get_subscription(From = #jid{}, StateData) ->
get_subscription(jlib:jid_tolower(From), StateData); get_subscription(jid:tolower(From), StateData);
get_subscription(LFrom, StateData) -> get_subscription(LFrom, StateData) ->
LBFrom = setelement(3, LFrom, <<"">>), LBFrom = setelement(3, LFrom, <<"">>),
F = (?SETS):is_element(LFrom, StateData#state.pres_f) F = (?SETS):is_element(LFrom, StateData#state.pres_f)
@ -347,7 +347,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
Server = Server =
case StateData#state.server of case StateData#state.server of
<<"">> -> <<"">> ->
jlib:nameprep(xml:get_attr_s(<<"to">>, Attrs)); jid:nameprep(xml:get_attr_s(<<"to">>, Attrs));
S -> S S -> S
end, end,
Lang = case xml:get_attr_s(<<"xml:lang">>, Attrs) of Lang = case xml:get_attr_s(<<"xml:lang">>, Attrs) of
@ -366,7 +366,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs}, StateData) ->
IsBlacklistedIP = is_ip_blacklisted(StateData#state.ip, Lang), IsBlacklistedIP = is_ip_blacklisted(StateData#state.ip, Lang),
case lists:member(Server, ?MYHOSTS) of case lists:member(Server, ?MYHOSTS) of
true when IsBlacklistedIP == false -> true when IsBlacklistedIP == false ->
change_shaper(StateData, jlib:make_jid(<<"">>, Server, <<"">>)), change_shaper(StateData, jid:make(<<"">>, Server, <<"">>)),
case xml:get_attr_s(<<"version">>, Attrs) of case xml:get_attr_s(<<"version">>, Attrs) of
<<"1.0">> -> <<"1.0">> ->
send_header(StateData, Server, <<"1.0">>, DefaultLang), send_header(StateData, Server, <<"1.0">>, DefaultLang),
@ -605,7 +605,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
send_element(StateData, Err), send_element(StateData, Err),
fsm_next_state(wait_for_auth, StateData); fsm_next_state(wait_for_auth, StateData);
{auth, _ID, set, {U, P, D, R}} -> {auth, _ID, set, {U, P, D, R}} ->
JID = jlib:make_jid(U, StateData#state.server, R), JID = jid:make(U, StateData#state.server, R),
case JID /= error andalso case JID /= error andalso
acl:match_rule(StateData#state.server, acl:match_rule(StateData#state.server,
StateData#state.access, JID) StateData#state.access, JID)
@ -622,7 +622,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
{true, AuthModule} -> {true, AuthModule} ->
?INFO_MSG("(~w) Accepted legacy authentication for ~s by ~p from ~s", ?INFO_MSG("(~w) Accepted legacy authentication for ~s by ~p from ~s",
[StateData#state.socket, [StateData#state.socket,
jlib:jid_to_string(JID), AuthModule, jid:to_string(JID), AuthModule,
ejabberd_config:may_hide_data(jlib:ip_to_list(StateData#state.ip))]), ejabberd_config:may_hide_data(jlib:ip_to_list(StateData#state.ip))]),
ejabberd_hooks:run(c2s_auth_result, StateData#state.server, ejabberd_hooks:run(c2s_auth_result, StateData#state.server,
[true, U, StateData#state.server, [true, U, StateData#state.server,
@ -642,7 +642,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
StateData#state.server, StateData#state.server,
{[], []}, {[], []},
[U, StateData#state.server]), [U, StateData#state.server]),
LJID = jlib:jid_tolower(jlib:jid_remove_resource(JID)), LJID = jid:tolower(jid:remove_resource(JID)),
Fs1 = [LJID | Fs], Fs1 = [LJID | Fs],
Ts1 = [LJID | Ts], Ts1 = [LJID | Ts],
PrivList = ejabberd_hooks:run_fold(privacy_get_user_list, PrivList = ejabberd_hooks:run_fold(privacy_get_user_list,
@ -661,7 +661,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
_ -> _ ->
?INFO_MSG("(~w) Failed legacy authentication for ~s from ~s", ?INFO_MSG("(~w) Failed legacy authentication for ~s from ~s",
[StateData#state.socket, [StateData#state.socket,
jlib:jid_to_string(JID), jid:to_string(JID),
ejabberd_config:may_hide_data(jlib:ip_to_list(StateData#state.ip))]), ejabberd_config:may_hide_data(jlib:ip_to_list(StateData#state.ip))]),
ejabberd_hooks:run(c2s_auth_result, StateData#state.server, ejabberd_hooks:run(c2s_auth_result, StateData#state.server,
[false, U, StateData#state.server, [false, U, StateData#state.server,
@ -682,7 +682,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
?INFO_MSG("(~w) Forbidden legacy authentication " ?INFO_MSG("(~w) Forbidden legacy authentication "
"for ~s from ~s", "for ~s from ~s",
[StateData#state.socket, [StateData#state.socket,
jlib:jid_to_string(JID), jid:to_string(JID),
ejabberd_config:may_hide_data(jlib:ip_to_list(StateData#state.ip))]), ejabberd_config:may_hide_data(jlib:ip_to_list(StateData#state.ip))]),
ejabberd_hooks:run(c2s_auth_result, StateData#state.server, ejabberd_hooks:run(c2s_auth_result, StateData#state.server,
[false, U, StateData#state.server, [false, U, StateData#state.server,
@ -1038,7 +1038,7 @@ wait_for_bind({xmlstreamelement, El}, StateData) ->
U = StateData#state.user, U = StateData#state.user,
R1 = xml:get_path_s(SubEl, R1 = xml:get_path_s(SubEl,
[{elem, <<"resource">>}, cdata]), [{elem, <<"resource">>}, cdata]),
R = case jlib:resourceprep(R1) of R = case jid:resourceprep(R1) of
error -> error; error -> error;
<<"">> -> <<"">> ->
iolist_to_binary([randoms:get_string() iolist_to_binary([randoms:get_string()
@ -1063,7 +1063,7 @@ wait_for_bind({xmlstreamelement, El}, StateData) ->
send_element(StateData, Err), send_element(StateData, Err),
fsm_next_state(wait_for_bind, StateData); fsm_next_state(wait_for_bind, StateData);
{accept_resource, R2} -> {accept_resource, R2} ->
JID = jlib:make_jid(U, StateData#state.server, R2), JID = jid:make(U, StateData#state.server, R2),
Res = IQ#iq{type = result, Res = IQ#iq{type = result,
sub_el = sub_el =
[#xmlel{name = <<"bind">>, [#xmlel{name = <<"bind">>,
@ -1073,7 +1073,7 @@ wait_for_bind({xmlstreamelement, El}, StateData) ->
attrs = [], attrs = [],
children = children =
[{xmlcdata, [{xmlcdata,
jlib:jid_to_string(JID)}]}]}]}, jid:to_string(JID)}]}]}]},
send_element(StateData, jlib:iq_to_xml(Res)), send_element(StateData, jlib:iq_to_xml(Res)),
fsm_next_state(wait_for_session, fsm_next_state(wait_for_session,
StateData#state{resource = R2, jid = JID}) StateData#state{resource = R2, jid = JID})
@ -1108,7 +1108,7 @@ wait_for_session({xmlstreamelement, El}, StateData) ->
NewStateData#state.access, JID) of NewStateData#state.access, JID) of
allow -> allow ->
?INFO_MSG("(~w) Opened session for ~s", ?INFO_MSG("(~w) Opened session for ~s",
[NewStateData#state.socket, jlib:jid_to_string(JID)]), [NewStateData#state.socket, jid:to_string(JID)]),
Res = jlib:make_result_iq_reply(El#xmlel{children = []}), Res = jlib:make_result_iq_reply(El#xmlel{children = []}),
NewState = send_stanza(NewStateData, Res), NewState = send_stanza(NewStateData, Res),
change_shaper(NewState, JID), change_shaper(NewState, JID),
@ -1117,7 +1117,7 @@ wait_for_session({xmlstreamelement, El}, StateData) ->
NewState#state.server, NewState#state.server,
{[], []}, {[], []},
[U, NewState#state.server]), [U, NewState#state.server]),
LJID = jlib:jid_tolower(jlib:jid_remove_resource(JID)), LJID = jid:tolower(jid:remove_resource(JID)),
Fs1 = [LJID | Fs], Fs1 = [LJID | Fs],
Ts1 = [LJID | Ts], Ts1 = [LJID | Ts],
PrivList = PrivList =
@ -1143,7 +1143,7 @@ wait_for_session({xmlstreamelement, El}, StateData) ->
ejabberd_hooks:run(forbidden_session_hook, ejabberd_hooks:run(forbidden_session_hook,
NewStateData#state.server, [JID]), NewStateData#state.server, [JID]),
?INFO_MSG("(~w) Forbidden session for ~s", ?INFO_MSG("(~w) Forbidden session for ~s",
[NewStateData#state.socket, jlib:jid_to_string(JID)]), [NewStateData#state.socket, jid:to_string(JID)]),
Err = jlib:make_error_reply(El, ?ERR_NOT_ALLOWED), Err = jlib:make_error_reply(El, ?ERR_NOT_ALLOWED),
send_element(NewStateData, Err), send_element(NewStateData, Err),
fsm_next_state(wait_for_session, NewStateData) fsm_next_state(wait_for_session, NewStateData)
@ -1226,8 +1226,8 @@ session_established2(El, StateData) ->
FromJID = NewStateData#state.jid, FromJID = NewStateData#state.jid,
To = xml:get_attr_s(<<"to">>, Attrs), To = xml:get_attr_s(<<"to">>, Attrs),
ToJID = case To of ToJID = case To of
<<"">> -> jlib:make_jid(User, Server, <<"">>); <<"">> -> jid:make(User, Server, <<"">>);
_ -> jlib:string_to_jid(To) _ -> jid:from_string(To)
end, end,
NewEl1 = jlib:remove_attr(<<"xmlns">>, El), NewEl1 = jlib:remove_attr(<<"xmlns">>, El),
NewEl = case xml:get_attr_s(<<"xml:lang">>, Attrs) of NewEl = case xml:get_attr_s(<<"xml:lang">>, Attrs) of
@ -1303,7 +1303,7 @@ wait_for_resume({xmlstreamelement, _El} = Event, StateData) ->
fsm_next_state(wait_for_resume, StateData); fsm_next_state(wait_for_resume, StateData);
wait_for_resume(timeout, StateData) -> wait_for_resume(timeout, StateData) ->
?DEBUG("Timed out waiting for resumption of stream for ~s", ?DEBUG("Timed out waiting for resumption of stream for ~s",
[jlib:jid_to_string(StateData#state.jid)]), [jid:to_string(StateData#state.jid)]),
{stop, normal, StateData}; {stop, normal, StateData};
wait_for_resume(Event, StateData) -> wait_for_resume(Event, StateData) ->
?DEBUG("Ignoring event while waiting for resumption: ~p", [Event]), ?DEBUG("Ignoring event while waiting for resumption: ~p", [Event]),
@ -1395,7 +1395,7 @@ handle_info({route, _From, _To, {broadcast, Data}},
PrivListName}], PrivListName}],
children = []}]}]}, children = []}]}]},
PrivPushEl = jlib:replace_from_to( PrivPushEl = jlib:replace_from_to(
jlib:jid_remove_resource(StateData#state.jid), jid:remove_resource(StateData#state.jid),
StateData#state.jid, StateData#state.jid,
jlib:iq_to_xml(PrivPushIQ)), jlib:iq_to_xml(PrivPushIQ)),
NewState = send_stanza( NewState = send_stanza(
@ -1423,9 +1423,9 @@ handle_info({route, From, To,
Packet}]), Packet}]),
case xml:get_attr_s(<<"type">>, Attrs) of case xml:get_attr_s(<<"type">>, Attrs) of
<<"probe">> -> <<"probe">> ->
LFrom = jlib:jid_tolower(From), LFrom = jid:tolower(From),
LBFrom = LBFrom =
jlib:jid_remove_resource(LFrom), jid:remove_resource(LFrom),
NewStateData = case NewStateData = case
(?SETS):is_element(LFrom, (?SETS):is_element(LFrom,
State#state.pres_a) State#state.pres_a)
@ -1468,7 +1468,7 @@ handle_info({route, From, To,
{false, Attrs, NewStateData}; {false, Attrs, NewStateData};
<<"error">> -> <<"error">> ->
NewA = NewA =
remove_element(jlib:jid_tolower(From), remove_element(jid:tolower(From),
State#state.pres_a), State#state.pres_a),
{true, Attrs, {true, Attrs,
State#state{pres_a = NewA}}; State#state{pres_a = NewA}};
@ -1504,9 +1504,9 @@ handle_info({route, From, To,
of of
allow -> allow ->
LFrom = LFrom =
jlib:jid_tolower(From), jid:tolower(From),
LBFrom = LBFrom =
jlib:jid_remove_resource(LFrom), jid:remove_resource(LFrom),
case case
(?SETS):is_element(LFrom, (?SETS):is_element(LFrom,
State#state.pres_a) State#state.pres_a)
@ -1557,9 +1557,9 @@ handle_info({route, From, To,
IQ = jlib:iq_query_info(Packet), IQ = jlib:iq_query_info(Packet),
case IQ of case IQ of
#iq{xmlns = ?NS_LAST} -> #iq{xmlns = ?NS_LAST} ->
LFrom = jlib:jid_tolower(From), LFrom = jid:tolower(From),
LBFrom = LBFrom =
jlib:jid_remove_resource(LFrom), jid:remove_resource(LFrom),
HasFromSub = HasFromSub =
((?SETS):is_element(LFrom, ((?SETS):is_element(LFrom,
StateData#state.pres_f) StateData#state.pres_f)
@ -1654,8 +1654,8 @@ handle_info({route, From, To,
end, end,
if Pass -> if Pass ->
Attrs2 = Attrs2 =
jlib:replace_from_to_attrs(jlib:jid_to_string(From), jlib:replace_from_to_attrs(jid:to_string(From),
jlib:jid_to_string(To), NewAttrs), jid:to_string(To), NewAttrs),
FixedPacket0 = #xmlel{name = Name, attrs = Attrs2, children = Els}, FixedPacket0 = #xmlel{name = Name, attrs = Attrs2, children = Els},
FixedPacket = ejabberd_hooks:run_fold( FixedPacket = ejabberd_hooks:run_fold(
user_receive_packet, user_receive_packet,
@ -1717,8 +1717,8 @@ handle_info({send_filtered, Feature, From, To, Packet}, StateName, StateData) ->
Feature, To, Packet]), Feature, To, Packet]),
NewStateData = if Drop -> NewStateData = if Drop ->
?DEBUG("Dropping packet from ~p to ~p", ?DEBUG("Dropping packet from ~p to ~p",
[jlib:jid_to_string(From), [jid:to_string(From),
jlib:jid_to_string(To)]), jid:to_string(To)]),
StateData; StateData;
true -> true ->
FinalPacket = jlib:replace_from_to(From, To, Packet), FinalPacket = jlib:replace_from_to(From, To, Packet),
@ -1745,7 +1745,7 @@ handle_info({broadcast, Type, From, Packet}, StateName, StateData) ->
lists:foreach( lists:foreach(
fun(USR) -> fun(USR) ->
ejabberd_router:route( ejabberd_router:route(
From, jlib:make_jid(USR), Packet) From, jid:make(USR), Packet)
end, lists:usort(Recipients)), end, lists:usort(Recipients)),
fsm_next_state(StateName, StateData); fsm_next_state(StateName, StateData);
handle_info(Info, StateName, StateData) -> handle_info(Info, StateName, StateData) ->
@ -1761,7 +1761,7 @@ terminate(_Reason, StateName, StateData) ->
case StateData#state.mgmt_state of case StateData#state.mgmt_state of
resumed -> resumed ->
?INFO_MSG("Closing former stream of resumed session for ~s", ?INFO_MSG("Closing former stream of resumed session for ~s",
[jlib:jid_to_string(StateData#state.jid)]); [jid:to_string(StateData#state.jid)]);
_ -> _ ->
if StateName == session_established; if StateName == session_established;
StateName == wait_for_resume -> StateName == wait_for_resume ->
@ -1769,7 +1769,7 @@ terminate(_Reason, StateName, StateData) ->
replaced -> replaced ->
?INFO_MSG("(~w) Replaced session for ~s", ?INFO_MSG("(~w) Replaced session for ~s",
[StateData#state.socket, [StateData#state.socket,
jlib:jid_to_string(StateData#state.jid)]), jid:to_string(StateData#state.jid)]),
From = StateData#state.jid, From = StateData#state.jid,
Packet = #xmlel{name = <<"presence">>, Packet = #xmlel{name = <<"presence">>,
attrs = [{<<"type">>, <<"unavailable">>}], attrs = [{<<"type">>, <<"unavailable">>}],
@ -1789,7 +1789,7 @@ terminate(_Reason, StateName, StateData) ->
_ -> _ ->
?INFO_MSG("(~w) Close session for ~s", ?INFO_MSG("(~w) Close session for ~s",
[StateData#state.socket, [StateData#state.socket,
jlib:jid_to_string(StateData#state.jid)]), jid:to_string(StateData#state.jid)]),
EmptySet = (?SETS):new(), EmptySet = (?SETS):new(),
case StateData of case StateData of
#state{pres_last = undefined, pres_a = EmptySet} -> #state{pres_last = undefined, pres_a = EmptySet} ->
@ -1978,7 +1978,7 @@ get_conn_type(StateData) ->
end. end.
process_presence_probe(From, To, StateData) -> process_presence_probe(From, To, StateData) ->
LFrom = jlib:jid_tolower(From), LFrom = jid:tolower(From),
LBFrom = setelement(3, LFrom, <<"">>), LBFrom = setelement(3, LFrom, <<"">>),
case StateData#state.pres_last of case StateData#state.pres_last of
undefined -> undefined ->
@ -2076,7 +2076,7 @@ presence_update(From, Packet, StateData) ->
%% User sends a directed presence packet %% User sends a directed presence packet
presence_track(From, To, Packet, StateData) -> presence_track(From, To, Packet, StateData) ->
#xmlel{attrs = Attrs} = Packet, #xmlel{attrs = Attrs} = Packet,
LTo = jlib:jid_tolower(To), LTo = jid:tolower(To),
User = StateData#state.user, User = StateData#state.user,
Server = StateData#state.server, Server = StateData#state.server,
case xml:get_attr_s(<<"type">>, Attrs) of case xml:get_attr_s(<<"type">>, Attrs) of
@ -2089,14 +2089,14 @@ presence_track(From, To, Packet, StateData) ->
ejabberd_hooks:run(roster_out_subscription, Server, ejabberd_hooks:run(roster_out_subscription, Server,
[User, Server, To, subscribed]), [User, Server, To, subscribed]),
check_privacy_route(From, StateData, check_privacy_route(From, StateData,
jlib:jid_remove_resource(From), To, Packet); jid:remove_resource(From), To, Packet);
<<"unsubscribe">> -> <<"unsubscribe">> ->
try_roster_subscribe(unsubscribe, User, Server, From, To, Packet, StateData); try_roster_subscribe(unsubscribe, User, Server, From, To, Packet, StateData);
<<"unsubscribed">> -> <<"unsubscribed">> ->
ejabberd_hooks:run(roster_out_subscription, Server, ejabberd_hooks:run(roster_out_subscription, Server,
[User, Server, To, unsubscribed]), [User, Server, To, unsubscribed]),
check_privacy_route(From, StateData, check_privacy_route(From, StateData,
jlib:jid_remove_resource(From), To, Packet); jid:remove_resource(From), To, Packet);
<<"error">> -> <<"error">> ->
check_privacy_route(From, StateData, From, To, Packet); check_privacy_route(From, StateData, From, To, Packet);
<<"probe">> -> <<"probe">> ->
@ -2139,7 +2139,7 @@ is_privacy_allow(StateData, From, To, Packet, Dir) ->
%%% Check ACL before allowing to send a subscription stanza %%% Check ACL before allowing to send a subscription stanza
try_roster_subscribe(Type, User, Server, From, To, Packet, StateData) -> try_roster_subscribe(Type, User, Server, From, To, Packet, StateData) ->
JID1 = jlib:make_jid(User, Server, <<"">>), JID1 = jid:make(User, Server, <<"">>),
Access = gen_mod:get_module_opt(Server, mod_roster, access, fun(A) when is_atom(A) -> A end, all), Access = gen_mod:get_module_opt(Server, mod_roster, access, fun(A) when is_atom(A) -> A end, all),
case acl:match_rule(Server, Access, JID1) of case acl:match_rule(Server, Access, JID1) of
deny -> deny ->
@ -2149,7 +2149,7 @@ try_roster_subscribe(Type, User, Server, From, To, Packet, StateData) ->
ejabberd_hooks:run(roster_out_subscription, ejabberd_hooks:run(roster_out_subscription,
Server, Server,
[User, Server, To, Type]), [User, Server, To, Type]),
check_privacy_route(From, StateData, jlib:jid_remove_resource(From), check_privacy_route(From, StateData, jid:remove_resource(From),
To, Packet) To, Packet)
end. end.
@ -2191,7 +2191,7 @@ presence_broadcast_first(From, StateData, Packet) ->
StateData#state{pres_a = As}. StateData#state{pres_a = As}.
format_and_check_privacy(From, StateData, Packet, JIDs, Dir) -> format_and_check_privacy(From, StateData, Packet, JIDs, Dir) ->
FJIDs = [jlib:make_jid(JID) || JID <- JIDs], FJIDs = [jid:make(JID) || JID <- JIDs],
lists:filter( lists:filter(
fun(FJID) -> fun(FJID) ->
case ejabberd_hooks:run_fold( case ejabberd_hooks:run_fold(
@ -2218,7 +2218,7 @@ remove_element(E, Set) ->
end. end.
roster_change(IJID, ISubscription, StateData) -> roster_change(IJID, ISubscription, StateData) ->
LIJID = jlib:jid_tolower(IJID), LIJID = jid:tolower(IJID),
IsFrom = (ISubscription == both) or (ISubscription == from), IsFrom = (ISubscription == both) or (ISubscription == from),
IsTo = (ISubscription == both) or (ISubscription == to), IsTo = (ISubscription == both) or (ISubscription == to),
OldIsFrom = (?SETS):is_element(LIJID, StateData#state.pres_f), OldIsFrom = (?SETS):is_element(LIJID, StateData#state.pres_f),
@ -2237,7 +2237,7 @@ roster_change(IJID, ISubscription, StateData) ->
?DEBUG("roster changed for ~p~n", ?DEBUG("roster changed for ~p~n",
[StateData#state.user]), [StateData#state.user]),
From = StateData#state.jid, From = StateData#state.jid,
To = jlib:make_jid(IJID), To = jid:make(IJID),
Cond1 = IsFrom andalso not OldIsFrom, Cond1 = IsFrom andalso not OldIsFrom,
Cond2 = not IsFrom andalso OldIsFrom andalso Cond2 = not IsFrom andalso OldIsFrom andalso
((?SETS):is_element(LIJID, StateData#state.pres_a)), ((?SETS):is_element(LIJID, StateData#state.pres_a)),
@ -2385,10 +2385,10 @@ process_unauthenticated_stanza(StateData, El) ->
empty -> empty ->
ResIQ = IQ#iq{type = error, ResIQ = IQ#iq{type = error,
sub_el = [?ERR_SERVICE_UNAVAILABLE]}, sub_el = [?ERR_SERVICE_UNAVAILABLE]},
Res1 = jlib:replace_from_to(jlib:make_jid(<<"">>, Res1 = jlib:replace_from_to(jid:make(<<"">>,
StateData#state.server, StateData#state.server,
<<"">>), <<"">>),
jlib:make_jid(<<"">>, <<"">>, jid:make(<<"">>, <<"">>,
<<"">>), <<"">>),
jlib:iq_to_xml(ResIQ)), jlib:iq_to_xml(ResIQ)),
send_element(StateData, send_element(StateData,
@ -2426,7 +2426,7 @@ fsm_next_state_gc(StateName, PackedStateData) ->
fsm_next_state(session_established, #state{mgmt_max_queue = exceeded} = fsm_next_state(session_established, #state{mgmt_max_queue = exceeded} =
StateData) -> StateData) ->
?WARNING_MSG("ACK queue too long, terminating session for ~s", ?WARNING_MSG("ACK queue too long, terminating session for ~s",
[jlib:jid_to_string(StateData#state.jid)]), [jid:to_string(StateData#state.jid)]),
Err = ?SERRT_POLICY_VIOLATION(StateData#state.lang, Err = ?SERRT_POLICY_VIOLATION(StateData#state.lang,
<<"Too many unacked stanzas">>), <<"Too many unacked stanzas">>),
send_element(StateData, Err), send_element(StateData, Err),
@ -2442,7 +2442,7 @@ fsm_next_state(wait_for_resume, #state{mgmt_timeout = 0} = StateData) ->
fsm_next_state(wait_for_resume, #state{mgmt_pending_since = undefined} = fsm_next_state(wait_for_resume, #state{mgmt_pending_since = undefined} =
StateData) -> StateData) ->
?INFO_MSG("Waiting for resumption of stream for ~s", ?INFO_MSG("Waiting for resumption of stream for ~s",
[jlib:jid_to_string(StateData#state.jid)]), [jid:to_string(StateData#state.jid)]),
{next_state, wait_for_resume, {next_state, wait_for_resume,
StateData#state{mgmt_state = pending, mgmt_pending_since = os:timestamp()}, StateData#state{mgmt_state = pending, mgmt_pending_since = os:timestamp()},
StateData#state.mgmt_timeout}; StateData#state.mgmt_timeout};
@ -2477,7 +2477,7 @@ check_from(El, FromJID) ->
false -> false ->
El; El;
{value, SJID} -> {value, SJID} ->
JID = jlib:string_to_jid(SJID), JID = jid:from_string(SJID),
case JID of case JID of
error -> error ->
'invalid-from'; 'invalid-from';
@ -2530,7 +2530,7 @@ route_blocking(What, StateData) ->
#xmlel{name = <<"item">>, #xmlel{name = <<"item">>,
attrs = attrs =
[{<<"jid">>, [{<<"jid">>,
jlib:jid_to_string(JID)}], jid:to_string(JID)}],
children = []} children = []}
end, end,
JIDs)}; JIDs)};
@ -2542,7 +2542,7 @@ route_blocking(What, StateData) ->
#xmlel{name = <<"item">>, #xmlel{name = <<"item">>,
attrs = attrs =
[{<<"jid">>, [{<<"jid">>,
jlib:jid_to_string(JID)}], jid:to_string(JID)}],
children = []} children = []}
end, end,
JIDs)}; JIDs)};
@ -2552,7 +2552,7 @@ route_blocking(What, StateData) ->
end, end,
PrivPushIQ = #iq{type = set, id = <<"push">>, sub_el = [SubEl]}, PrivPushIQ = #iq{type = set, id = <<"push">>, sub_el = [SubEl]},
PrivPushEl = PrivPushEl =
jlib:replace_from_to(jlib:jid_remove_resource(StateData#state.jid), jlib:replace_from_to(jid:remove_resource(StateData#state.jid),
StateData#state.jid, jlib:iq_to_xml(PrivPushIQ)), StateData#state.jid, jlib:iq_to_xml(PrivPushIQ)),
%% No need to replace active privacy list here, %% No need to replace active privacy list here,
%% blocking pushes are always accompanied by %% blocking pushes are always accompanied by
@ -2653,13 +2653,13 @@ handle_enable(#state{mgmt_timeout = DefaultTimeout,
ResAttrs = [{<<"xmlns">>, StateData#state.mgmt_xmlns}] ++ ResAttrs = [{<<"xmlns">>, StateData#state.mgmt_xmlns}] ++
if Timeout > 0 -> if Timeout > 0 ->
?INFO_MSG("Stream management with resumption enabled for ~s", ?INFO_MSG("Stream management with resumption enabled for ~s",
[jlib:jid_to_string(StateData#state.jid)]), [jid:to_string(StateData#state.jid)]),
[{<<"id">>, make_resume_id(StateData)}, [{<<"id">>, make_resume_id(StateData)},
{<<"resume">>, <<"true">>}, {<<"resume">>, <<"true">>},
{<<"max">>, jlib:integer_to_binary(Timeout)}]; {<<"max">>, jlib:integer_to_binary(Timeout)}];
true -> true ->
?INFO_MSG("Stream management without resumption enabled for ~s", ?INFO_MSG("Stream management without resumption enabled for ~s",
[jlib:jid_to_string(StateData#state.jid)]), [jid:to_string(StateData#state.jid)]),
[] []
end, end,
Res = #xmlel{name = <<"enabled">>, Res = #xmlel{name = <<"enabled">>,
@ -2685,7 +2685,7 @@ handle_a(StateData, Attrs) ->
check_h_attribute(StateData, H); check_h_attribute(StateData, H);
_ -> _ ->
?DEBUG("Ignoring invalid ACK element from ~s", ?DEBUG("Ignoring invalid ACK element from ~s",
[jlib:jid_to_string(StateData#state.jid)]), [jid:to_string(StateData#state.jid)]),
StateData StateData
end. end.
@ -2740,7 +2740,7 @@ handle_resume(StateData, Attrs) ->
FlushedState = csi_queue_flush(NewState), FlushedState = csi_queue_flush(NewState),
NewStateData = FlushedState#state{csi_state = active}, NewStateData = FlushedState#state{csi_state = active},
?INFO_MSG("Resumed session for ~s", ?INFO_MSG("Resumed session for ~s",
[jlib:jid_to_string(NewStateData#state.jid)]), [jid:to_string(NewStateData#state.jid)]),
{ok, NewStateData}; {ok, NewStateData};
{error, El, Msg} -> {error, El, Msg} ->
send_element(StateData, El), send_element(StateData, El),
@ -2752,11 +2752,11 @@ handle_resume(StateData, Attrs) ->
check_h_attribute(#state{mgmt_stanzas_out = NumStanzasOut} = StateData, H) check_h_attribute(#state{mgmt_stanzas_out = NumStanzasOut} = StateData, H)
when H > NumStanzasOut -> when H > NumStanzasOut ->
?DEBUG("~s acknowledged ~B stanzas, but only ~B were sent", ?DEBUG("~s acknowledged ~B stanzas, but only ~B were sent",
[jlib:jid_to_string(StateData#state.jid), H, NumStanzasOut]), [jid:to_string(StateData#state.jid), H, NumStanzasOut]),
mgmt_queue_drop(StateData#state{mgmt_stanzas_out = H}, NumStanzasOut); mgmt_queue_drop(StateData#state{mgmt_stanzas_out = H}, NumStanzasOut);
check_h_attribute(#state{mgmt_stanzas_out = NumStanzasOut} = StateData, H) -> check_h_attribute(#state{mgmt_stanzas_out = NumStanzasOut} = StateData, H) ->
?DEBUG("~s acknowledged ~B of ~B stanzas", ?DEBUG("~s acknowledged ~B of ~B stanzas",
[jlib:jid_to_string(StateData#state.jid), H, NumStanzasOut]), [jid:to_string(StateData#state.jid), H, NumStanzasOut]),
mgmt_queue_drop(StateData, H). mgmt_queue_drop(StateData, H).
update_num_stanzas_in(#state{mgmt_state = active} = StateData, El) -> update_num_stanzas_in(#state{mgmt_state = active} = StateData, El) ->
@ -2823,13 +2823,13 @@ handle_unacked_stanzas(StateData, F)
ok; ok;
N -> N ->
?INFO_MSG("~B stanzas were not acknowledged by ~s", ?INFO_MSG("~B stanzas were not acknowledged by ~s",
[N, jlib:jid_to_string(StateData#state.jid)]), [N, jid:to_string(StateData#state.jid)]),
lists:foreach( lists:foreach(
fun({_, Time, #xmlel{attrs = Attrs} = El}) -> fun({_, Time, #xmlel{attrs = Attrs} = El}) ->
From_s = xml:get_attr_s(<<"from">>, Attrs), From_s = xml:get_attr_s(<<"from">>, Attrs),
From = jlib:string_to_jid(From_s), From = jid:from_string(From_s),
To_s = xml:get_attr_s(<<"to">>, Attrs), To_s = xml:get_attr_s(<<"to">>, Attrs),
To = jlib:string_to_jid(To_s), To = jid:from_string(To_s),
F(From, To, El, Time) F(From, To, El, Time)
end, queue:to_list(Queue)) end, queue:to_list(Queue))
end; end;
@ -2863,7 +2863,7 @@ handle_unacked_stanzas(StateData)
end, end,
F = fun(From, _To, #xmlel{name = <<"presence">>}, _Time) -> F = fun(From, _To, #xmlel{name = <<"presence">>}, _Time) ->
?DEBUG("Dropping presence stanza from ~s", ?DEBUG("Dropping presence stanza from ~s",
[jlib:jid_to_string(From)]); [jid:to_string(From)]);
(From, To, #xmlel{name = <<"iq">>} = El, _Time) -> (From, To, #xmlel{name = <<"iq">>} = El, _Time) ->
Err = jlib:make_error_reply(El, ?ERR_SERVICE_UNAVAILABLE), Err = jlib:make_error_reply(El, ?ERR_SERVICE_UNAVAILABLE),
ejabberd_router:route(To, From, Err); ejabberd_router:route(To, From, Err);
@ -2986,7 +2986,7 @@ csi_filter_stanza(#state{csi_state = CsiState, jid = JID} = StateData,
StateData#state.server, StateData#state.server,
send, [Stanza]), send, [Stanza]),
?DEBUG("Going to ~p stanza for inactive client ~p", ?DEBUG("Going to ~p stanza for inactive client ~p",
[Action, jlib:jid_to_string(JID)]), [Action, jid:to_string(JID)]),
case Action of case Action of
queue -> csi_queue_add(StateData, Stanza); queue -> csi_queue_add(StateData, Stanza);
drop -> StateData; drop -> StateData;
@ -3021,7 +3021,7 @@ csi_queue_send(#state{csi_queue = Queue, csi_state = CsiState, server = Host} =
csi_queue_flush(#state{csi_queue = Queue, csi_state = CsiState, jid = JID, csi_queue_flush(#state{csi_queue = Queue, csi_state = CsiState, jid = JID,
server = Host} = StateData) -> server = Host} = StateData) ->
?DEBUG("Flushing CSI queue for ~s", [jlib:jid_to_string(JID)]), ?DEBUG("Flushing CSI queue for ~s", [jid:to_string(JID)]),
NewStateData = NewStateData =
lists:foldl(fun({_From, Time, Stanza}, AccState) -> lists:foldl(fun({_From, Time, Stanza}, AccState) ->
NewStanza = NewStanza =

View File

@ -88,7 +88,7 @@ create_captcha(SID, From, To, Lang, Limiter, Args) ->
{ok, Type, Key, Image} -> {ok, Type, Key, Image} ->
Id = <<(randoms:get_string())/binary>>, Id = <<(randoms:get_string())/binary>>,
B64Image = jlib:encode_base64((Image)), B64Image = jlib:encode_base64((Image)),
JID = jlib:jid_to_string(From), JID = jid:to_string(From),
CID = <<"sha1+", (p1_sha:sha(Image))/binary, CID = <<"sha1+", (p1_sha:sha(Image))/binary,
"@bob.xmpp.org">>, "@bob.xmpp.org">>,
Data = #xmlel{name = <<"data">>, Data = #xmlel{name = <<"data">>,
@ -109,7 +109,7 @@ create_captcha(SID, From, To, Lang, Limiter, Args) ->
{xmlcdata, ?NS_CAPTCHA}), {xmlcdata, ?NS_CAPTCHA}),
?VFIELD(<<"hidden">>, <<"from">>, ?VFIELD(<<"hidden">>, <<"from">>,
{xmlcdata, {xmlcdata,
jlib:jid_to_string(To)}), jid:to_string(To)}),
?VFIELD(<<"hidden">>, ?VFIELD(<<"hidden">>,
<<"challenge">>, <<"challenge">>,
{xmlcdata, Id}), {xmlcdata, Id}),
@ -233,7 +233,7 @@ create_captcha_x(SID, To, Lang, Limiter, HeadEls,
[{xmlcdata, [{xmlcdata,
Imageurl}]}]}, Imageurl}]}]},
?VFIELD(<<"hidden">>, <<"from">>, ?VFIELD(<<"hidden">>, <<"from">>,
{xmlcdata, jlib:jid_to_string(To)}), {xmlcdata, jid:to_string(To)}),
?VFIELD(<<"hidden">>, <<"challenge">>, ?VFIELD(<<"hidden">>, <<"challenge">>,
{xmlcdata, Id}), {xmlcdata, Id}),
?VFIELD(<<"hidden">>, <<"sid">>, ?VFIELD(<<"hidden">>, <<"sid">>,

View File

@ -514,7 +514,7 @@ check_access2(?POLICY_ACCESS, _User, _Server) ->
true; true;
check_access2(Access, User, Server) -> check_access2(Access, User, Server) ->
%% Check this user has access permission %% Check this user has access permission
case acl:match_rule(Server, Access, jlib:make_jid(User, Server, <<"">>)) of case acl:match_rule(Server, Access, jid:make(User, Server, <<"">>)) of
allow -> true; allow -> true;
deny -> false deny -> false
end. end.
@ -597,7 +597,7 @@ is_admin(Name, {User, Server, _, true} = Auth) ->
fun(A) when is_atom(A) -> A end, fun(A) when is_atom(A) -> A end,
none), none),
case acl:match_rule(Server, AdminAccess, case acl:match_rule(Server, AdminAccess,
jlib:make_jid(User, Server, <<"">>)) of jid:make(User, Server, <<"">>)) of
allow -> allow ->
case catch check_auth(get_command_definition(Name), Auth) of case catch check_auth(get_command_definition(Name), Auth) of
{ok, _, _} -> true; {ok, _, _} -> true;

View File

@ -306,7 +306,7 @@ normalize_hosts(Hosts) ->
normalize_hosts([], PrepHosts) -> normalize_hosts([], PrepHosts) ->
lists:reverse(PrepHosts); lists:reverse(PrepHosts);
normalize_hosts([Host|Hosts], PrepHosts) -> normalize_hosts([Host|Hosts], PrepHosts) ->
case jlib:nodeprep(iolist_to_binary(Host)) of case jid:nodeprep(iolist_to_binary(Host)) of
error -> error ->
?ERROR_MSG("Can't load config file: " ?ERROR_MSG("Can't load config file: "
"invalid host name [~p]", [Host]), "invalid host name [~p]", [Host]),

View File

@ -232,7 +232,7 @@ process_request(Data, IP, HOpts) ->
"dressing' xmlns='", "dressing' xmlns='",
(?NS_HTTP_BIND)/binary, "'/>">>}; (?NS_HTTP_BIND)/binary, "'/>">>};
XmppDomain -> XmppDomain ->
NXmppDomain = jlib:nameprep(XmppDomain), NXmppDomain = jid:nameprep(XmppDomain),
Sid = p1_sha:sha(term_to_binary({now(), make_ref()})), Sid = p1_sha:sha(term_to_binary({now(), make_ref()})),
case start(NXmppDomain, Sid, <<"">>, IP, HOpts) of case start(NXmppDomain, Sid, <<"">>, IP, HOpts) of
{error, _} -> {error, _} ->

View File

@ -125,7 +125,7 @@ get_client_identity(Client, Ctx) -> {ok, {Ctx, {client, Client}}}.
verify_redirection_uri(_, _, Ctx) -> {ok, Ctx}. verify_redirection_uri(_, _, Ctx) -> {ok, Ctx}.
authenticate_user({User, Server}, {password, Password} = Ctx) -> authenticate_user({User, Server}, {password, Password} = Ctx) ->
case jlib:make_jid(User, Server, <<"">>) of case jid:make(User, Server, <<"">>) of
#jid{} = JID -> #jid{} = JID ->
Access = Access =
ejabberd_config:get_option( ejabberd_config:get_option(
@ -173,8 +173,8 @@ associate_access_token(AccessToken, Context, AppContext) ->
proplists:get_value(<<"resource_owner">>, Context, <<"">>), proplists:get_value(<<"resource_owner">>, Context, <<"">>),
Scope = proplists:get_value(<<"scope">>, Context, []), Scope = proplists:get_value(<<"scope">>, Context, []),
Expire = proplists:get_value(<<"expiry_time">>, Context, 0), Expire = proplists:get_value(<<"expiry_time">>, Context, 0),
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
R = #oauth_token{ R = #oauth_token{
token = AccessToken, token = AccessToken,
us = {LUser, LServer}, us = {LUser, LServer},
@ -190,8 +190,8 @@ associate_refresh_token(RefreshToken, Context, AppContext) ->
check_token(User, Server, Scope, Token) -> check_token(User, Server, Scope, Token) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case catch mnesia:dirty_read(oauth_token, Token) of case catch mnesia:dirty_read(oauth_token, Token) of
[#oauth_token{us = {LUser, LServer}, [#oauth_token{us = {LUser, LServer},
scope = TokenScope, scope = TokenScope,

View File

@ -242,7 +242,7 @@ export_users([], _Server, _Fd) ->
%%%% Utilities %%%% Utilities
export_user(User, Server, Fd) -> export_user(User, Server, Fd) ->
Password = ejabberd_auth:get_password_s(User, Server), Password = ejabberd_auth:get_password_s(User, Server),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
PasswordFormat = ejabberd_config:get_option({auth_password_format, LServer}, fun(X) -> X end, plain), PasswordFormat = ejabberd_config:get_option({auth_password_format, LServer}, fun(X) -> X end, plain),
Pass = case Password of Pass = case Password of
{_,_,_,_} -> {_,_,_,_} ->
@ -281,7 +281,7 @@ parse_scram_password(PassData) ->
}. }.
get_vcard(User, Server) -> get_vcard(User, Server) ->
JID = jlib:make_jid(User, Server, <<>>), JID = jid:make(User, Server, <<>>),
case mod_vcard:process_sm_iq(JID, JID, #iq{type = get}) of case mod_vcard:process_sm_iq(JID, JID, #iq{type = get}) of
#iq{type = result, sub_el = [_|_] = VCardEls} -> #iq{type = result, sub_el = [_|_] = VCardEls} ->
VCardEls; VCardEls;
@ -335,7 +335,7 @@ get_privacy(User, Server) ->
%% @spec (Dir::string(), Hosts::[string()]) -> ok %% @spec (Dir::string(), Hosts::[string()]) -> ok
get_roster(User, Server) -> get_roster(User, Server) ->
JID = jlib:make_jid(User, Server, <<>>), JID = jid:make(User, Server, <<>>),
case mod_roster:get_roster(User, Server) of case mod_roster:get_roster(User, Server) of
[_|_] = Items -> [_|_] = Items ->
Subs = Subs =
@ -349,8 +349,8 @@ get_roster(User, Server) ->
[#xmlel{name = <<"presence">>, [#xmlel{name = <<"presence">>,
attrs = attrs =
[{<<"from">>, [{<<"from">>,
jlib:jid_to_string(R#roster.jid)}, jid:to_string(R#roster.jid)},
{<<"to">>, jlib:jid_to_string(JID)}, {<<"to">>, jid:to_string(JID)},
{<<"xmlns">>, <<"jabber:client">>}, {<<"xmlns">>, <<"jabber:client">>},
{<<"type">>, <<"subscribe">>}], {<<"type">>, <<"subscribe">>}],
children = children =
@ -444,7 +444,7 @@ process_el({xmlstreamelement, #xmlel{name = <<"host">>,
attrs = Attrs, attrs = Attrs,
children = Els}}, State) -> children = Els}}, State) ->
JIDS = xml:get_attr_s(<<"jid">>, Attrs), JIDS = xml:get_attr_s(<<"jid">>, Attrs),
case jlib:string_to_jid(JIDS) of case jid:from_string(JIDS) of
#jid{lserver = S} -> #jid{lserver = S} ->
case lists:member(S, ?MYHOSTS) of case lists:member(S, ?MYHOSTS) of
true -> true ->
@ -499,7 +499,7 @@ process_user(#xmlel{name = <<"user">>, attrs = Attrs, children = Els},
_ -> Password _ -> Password
end, end,
case jlib:nodeprep(Name) of case jid:nodeprep(Name) of
error -> error ->
stop("Invalid 'user': ~s", [Name]); stop("Invalid 'user': ~s", [Name]);
LUser -> LUser ->
@ -579,7 +579,7 @@ process_roster(El, State = #state{user = U, server = S}) ->
%%%================================== %%%==================================
%%%% Export server %%%% Export server
process_privacy(El, State = #state{user = U, server = S}) -> process_privacy(El, State = #state{user = U, server = S}) ->
JID = jlib:make_jid(U, S, <<"">>), JID = jid:make(U, S, <<"">>),
case mod_privacy:process_iq_set( case mod_privacy:process_iq_set(
[], JID, JID, #iq{type = set, sub_el = El}) of [], JID, JID, #iq{type = set, sub_el = El}) of
{error, Error} = Err -> {error, Error} = Err ->
@ -605,7 +605,7 @@ process_privacy(El, State = #state{user = U, server = S}) ->
%% @spec (Dir::string()) -> ok %% @spec (Dir::string()) -> ok
process_private(El, State = #state{user = U, server = S}) -> process_private(El, State = #state{user = U, server = S}) ->
JID = jlib:make_jid(U, S, <<"">>), JID = jid:make(U, S, <<"">>),
case mod_private:process_sm_iq( case mod_private:process_sm_iq(
JID, JID, #iq{type = set, sub_el = El}) of JID, JID, #iq{type = set, sub_el = El}) of
#iq{type = result} -> #iq{type = result} ->
@ -617,7 +617,7 @@ process_private(El, State = #state{user = U, server = S}) ->
%%%================================== %%%==================================
%%%% Export host %%%% Export host
process_vcard(El, State = #state{user = U, server = S}) -> process_vcard(El, State = #state{user = U, server = S}) ->
JID = jlib:make_jid(U, S, <<"">>), JID = jid:make(U, S, <<"">>),
case mod_vcard:process_sm_iq( case mod_vcard:process_sm_iq(
JID, JID, #iq{type = set, sub_el = El}) of JID, JID, #iq{type = set, sub_el = El}) of
#iq{type = result} -> #iq{type = result} ->
@ -629,9 +629,9 @@ process_vcard(El, State = #state{user = U, server = S}) ->
%% @spec (Dir::string(), Host::string()) -> ok %% @spec (Dir::string(), Host::string()) -> ok
process_offline_msg(El, State = #state{user = U, server = S}) -> process_offline_msg(El, State = #state{user = U, server = S}) ->
FromS = xml:get_attr_s(<<"from">>, El#xmlel.attrs), FromS = xml:get_attr_s(<<"from">>, El#xmlel.attrs),
case jlib:string_to_jid(FromS) of case jid:from_string(FromS) of
#jid{} = From -> #jid{} = From ->
To = jlib:make_jid(U, S, <<>>), To = jid:make(U, S, <<>>),
NewEl = jlib:replace_from_to(From, To, El), NewEl = jlib:replace_from_to(From, To, El),
case catch mod_offline:store_packet(From, To, NewEl) of case catch mod_offline:store_packet(From, To, NewEl) of
{'EXIT', _} = Err -> {'EXIT', _} = Err ->
@ -646,9 +646,9 @@ process_offline_msg(El, State = #state{user = U, server = S}) ->
%% @spec (Dir::string(), Fn::string(), Host::string()) -> ok %% @spec (Dir::string(), Fn::string(), Host::string()) -> ok
process_presence(El, #state{user = U, server = S} = State) -> process_presence(El, #state{user = U, server = S} = State) ->
FromS = xml:get_attr_s(<<"from">>, El#xmlel.attrs), FromS = xml:get_attr_s(<<"from">>, El#xmlel.attrs),
case jlib:string_to_jid(FromS) of case jid:from_string(FromS) of
#jid{} = From -> #jid{} = From ->
To = jlib:make_jid(U, S, <<>>), To = jid:make(U, S, <<>>),
NewEl = jlib:replace_from_to(From, To, El), NewEl = jlib:replace_from_to(From, To, El),
ejabberd_router:route(From, To, NewEl), ejabberd_router:route(From, To, NewEl),
{ok, State}; {ok, State};

View File

@ -75,7 +75,7 @@ start_odbc(Host, App) ->
%% Returns {true, App} if we have configured odbc for the given host %% Returns {true, App} if we have configured odbc for the given host
needs_odbc(Host) -> needs_odbc(Host) ->
LHost = jlib:nameprep(Host), LHost = jid:nameprep(Host),
case ejabberd_config:get_option({odbc_type, LHost}, case ejabberd_config:get_option({odbc_type, LHost},
fun(mysql) -> mysql; fun(mysql) -> mysql;
(pgsql) -> pgsql; (pgsql) -> pgsql;

View File

@ -99,7 +99,7 @@ register_route(Domain) ->
-spec register_route(binary(), local_hint()) -> term(). -spec register_route(binary(), local_hint()) -> term().
register_route(Domain, LocalHint) -> register_route(Domain, LocalHint) ->
case jlib:nameprep(Domain) of case jid:nameprep(Domain) of
error -> erlang:error({invalid_domain, Domain}); error -> erlang:error({invalid_domain, Domain});
LDomain -> LDomain ->
Pid = self(), Pid = self(),
@ -161,7 +161,7 @@ register_routes(Domains) ->
-spec unregister_route(binary()) -> term(). -spec unregister_route(binary()) -> term().
unregister_route(Domain) -> unregister_route(Domain) ->
case jlib:nameprep(Domain) of case jid:nameprep(Domain) of
error -> erlang:error({invalid_domain, Domain}); error -> erlang:error({invalid_domain, Domain});
LDomain -> LDomain ->
Pid = self(), Pid = self(),
@ -349,12 +349,12 @@ do_route(OrigFrom, OrigTo, OrigPacket) ->
of of
undefined -> now(); undefined -> now();
random -> now(); random -> now();
source -> jlib:jid_tolower(From); source -> jid:tolower(From);
destination -> jlib:jid_tolower(To); destination -> jid:tolower(To);
bare_source -> bare_source ->
jlib:jid_remove_resource(jlib:jid_tolower(From)); jid:remove_resource(jid:tolower(From));
bare_destination -> bare_destination ->
jlib:jid_remove_resource(jlib:jid_tolower(To)) jid:remove_resource(jid:tolower(To))
end, end,
case get_component_number(LDstDomain) of case get_component_number(LDstDomain) of
undefined -> undefined ->

View File

@ -69,7 +69,7 @@ route_multicast(From, Domain, Destinations, Packet) ->
end. end.
register_route(Domain) -> register_route(Domain) ->
case jlib:nameprep(Domain) of case jid:nameprep(Domain) of
error -> error ->
erlang:error({invalid_domain, Domain}); erlang:error({invalid_domain, Domain});
LDomain -> LDomain ->
@ -82,7 +82,7 @@ register_route(Domain) ->
end. end.
unregister_route(Domain) -> unregister_route(Domain) ->
case jlib:nameprep(Domain) of case jid:nameprep(Domain) of
error -> error ->
erlang:error({invalid_domain, Domain}); erlang:error({invalid_domain, Domain});
LDomain -> LDomain ->
@ -209,9 +209,9 @@ code_change(_OldVsn, State, _Extra) ->
do_route(From, Domain, Destinations, Packet) -> do_route(From, Domain, Destinations, Packet) ->
?DEBUG("route_multicast~n\tfrom ~s~n\tdomain ~s~n\tdestinations ~p~n\tpacket ~p~n", ?DEBUG("route_multicast~n\tfrom ~s~n\tdomain ~s~n\tdestinations ~p~n\tpacket ~p~n",
[jlib:jid_to_string(From), [jid:to_string(From),
Domain, Domain,
[jlib:jid_to_string(To) || To <- Destinations], [jid:to_string(To) || To <- Destinations],
Packet]), Packet]),
%% Try to find an appropriate multicast service %% Try to find an appropriate multicast service

View File

@ -311,8 +311,8 @@ do_route(From, To, Packet) ->
#xmlel{name = Name, attrs = Attrs, children = Els} = #xmlel{name = Name, attrs = Attrs, children = Els} =
Packet, Packet,
NewAttrs = NewAttrs =
jlib:replace_from_to_attrs(jlib:jid_to_string(From), jlib:replace_from_to_attrs(jid:to_string(From),
jlib:jid_to_string(To), Attrs), jid:to_string(To), Attrs),
#jid{lserver = MyServer} = From, #jid{lserver = MyServer} = From,
ejabberd_hooks:run(s2s_send_packet, MyServer, ejabberd_hooks:run(s2s_send_packet, MyServer,
[From, To, Packet]), [From, To, Packet]),
@ -386,7 +386,7 @@ choose_pid(From, Pids) ->
Ps -> Ps Ps -> Ps
end, end,
Pid = Pid =
lists:nth(erlang:phash(jlib:jid_remove_resource(From), lists:nth(erlang:phash(jid:remove_resource(From),
length(Pids1)), length(Pids1)),
Pids1), Pids1),
?DEBUG("Using ejabberd_s2s_out ~p~n", [Pid]), ?DEBUG("Using ejabberd_s2s_out ~p~n", [Pid]),
@ -431,7 +431,7 @@ new_connection(MyServer, Server, From, FromTo,
max_s2s_connections_number({From, To}) -> max_s2s_connections_number({From, To}) ->
case acl:match_rule(From, max_s2s_connections, case acl:match_rule(From, max_s2s_connections,
jlib:make_jid(<<"">>, To, <<"">>)) jid:make(<<"">>, To, <<"">>))
of of
Max when is_integer(Max) -> Max; Max when is_integer(Max) -> Max;
_ -> ?DEFAULT_MAX_S2S_CONNECTIONS_NUMBER _ -> ?DEFAULT_MAX_S2S_CONNECTIONS_NUMBER
@ -439,7 +439,7 @@ max_s2s_connections_number({From, To}) ->
max_s2s_connections_number_per_node({From, To}) -> max_s2s_connections_number_per_node({From, To}) ->
case acl:match_rule(From, max_s2s_connections_per_node, case acl:match_rule(From, max_s2s_connections_per_node,
jlib:make_jid(<<"">>, To, <<"">>)) jid:make(<<"">>, To, <<"">>))
of of
Max when is_integer(Max) -> Max; Max when is_integer(Max) -> Max;
_ -> ?DEFAULT_MAX_S2S_CONNECTIONS_NUMBER_PER_NODE _ -> ?DEFAULT_MAX_S2S_CONNECTIONS_NUMBER_PER_NODE
@ -550,7 +550,7 @@ allow_host1(MyHost, S2SHost) ->
s2s_access, s2s_access,
fun(A) when is_atom(A) -> A end, fun(A) when is_atom(A) -> A end,
all), all),
JID = jlib:make_jid(<<"">>, S2SHost, <<"">>), JID = jid:make(<<"">>, S2SHost, <<"">>),
case acl:match_rule(MyHost, Rule, JID) of case acl:match_rule(MyHost, Rule, JID) of
deny -> false; deny -> false;
allow -> allow ->
@ -639,7 +639,7 @@ get_cert_domains(Cert) ->
true -> error true -> error
end, end,
if D /= error -> if D /= error ->
case jlib:string_to_jid(D) of case jid:from_string(D) of
#jid{luser = <<"">>, lserver = LD, #jid{luser = <<"">>, lserver = LD,
lresource = <<"">>} -> lresource = <<"">>} ->
[LD]; [LD];
@ -675,7 +675,7 @@ get_cert_domains(Cert) ->
when when
is_binary(D) -> is_binary(D) ->
case case
jlib:string_to_jid((D)) jid:from_string((D))
of of
#jid{luser = #jid{luser =
<<"">>, <<"">>,
@ -698,7 +698,7 @@ get_cert_domains(Cert) ->
({dNSName, D}) ({dNSName, D})
when is_list(D) -> when is_list(D) ->
case case
jlib:string_to_jid(list_to_binary(D)) jid:from_string(list_to_binary(D))
of of
#jid{luser = <<"">>, #jid{luser = <<"">>,
lserver = LD, lserver = LD,

View File

@ -199,7 +199,7 @@ wait_for_stream({xmlstreamstart, _Name, Attrs},
send_text(StateData, send_text(StateData,
?STREAM_HEADER(<<" version='1.0'">>)), ?STREAM_HEADER(<<" version='1.0'">>)),
Auth = if StateData#state.tls_enabled -> Auth = if StateData#state.tls_enabled ->
case jlib:nameprep(xml:get_attr_s(<<"from">>, Attrs)) of case jid:nameprep(xml:get_attr_s(<<"from">>, Attrs)) of
From when From /= <<"">>, From /= error -> From when From /= <<"">>, From /= error ->
{Result, Message} = {Result, Message} =
ejabberd_s2s:check_peer_certificate(StateData#state.sockmod, ejabberd_s2s:check_peer_certificate(StateData#state.sockmod,
@ -360,7 +360,7 @@ wait_for_feature_request({xmlstreamelement, El},
?INFO_MSG("Accepted s2s EXTERNAL authentication for ~s (TLS=~p)", ?INFO_MSG("Accepted s2s EXTERNAL authentication for ~s (TLS=~p)",
[AuthDomain, StateData#state.tls_enabled]), [AuthDomain, StateData#state.tls_enabled]),
change_shaper(StateData, <<"">>, change_shaper(StateData, <<"">>,
jlib:make_jid(<<"">>, AuthDomain, <<"">>)), jid:make(<<"">>, AuthDomain, <<"">>)),
{next_state, wait_for_stream, {next_state, wait_for_stream,
StateData#state{streamid = new_id(), StateData#state{streamid = new_id(),
authenticated = true}}; authenticated = true}};
@ -403,8 +403,8 @@ stream_established({xmlstreamelement, El}, StateData) ->
case is_key_packet(El) of case is_key_packet(El) of
{key, To, From, Id, Key} -> {key, To, From, Id, Key} ->
?DEBUG("GET KEY: ~p", [{To, From, Id, Key}]), ?DEBUG("GET KEY: ~p", [{To, From, Id, Key}]),
LTo = jlib:nameprep(To), LTo = jid:nameprep(To),
LFrom = jlib:nameprep(From), LFrom = jid:nameprep(From),
case {ejabberd_s2s:allow_host(LTo, LFrom), case {ejabberd_s2s:allow_host(LTo, LFrom),
lists:member(LTo, lists:member(LTo,
ejabberd_router:dirty_get_all_domains())} ejabberd_router:dirty_get_all_domains())}
@ -418,7 +418,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
wait_for_verification, wait_for_verification,
StateData#state.connections), StateData#state.connections),
change_shaper(StateData, LTo, change_shaper(StateData, LTo,
jlib:make_jid(<<"">>, LFrom, <<"">>)), jid:make(<<"">>, LFrom, <<"">>)),
{next_state, stream_established, {next_state, stream_established,
StateData#state{connections = Conns, timer = Timer}}; StateData#state{connections = Conns, timer = Timer}};
{_, false} -> {_, false} ->
@ -430,8 +430,8 @@ stream_established({xmlstreamelement, El}, StateData) ->
end; end;
{verify, To, From, Id, Key} -> {verify, To, From, Id, Key} ->
?DEBUG("VERIFY KEY: ~p", [{To, From, Id, Key}]), ?DEBUG("VERIFY KEY: ~p", [{To, From, Id, Key}]),
LTo = jlib:nameprep(To), LTo = jid:nameprep(To),
LFrom = jlib:nameprep(From), LFrom = jid:nameprep(From),
Type = case ejabberd_s2s:has_key({LTo, LFrom}, Key) of Type = case ejabberd_s2s:has_key({LTo, LFrom}, Key) of
true -> <<"valid">>; true -> <<"valid">>;
_ -> <<"invalid">> _ -> <<"invalid">>
@ -448,9 +448,9 @@ stream_established({xmlstreamelement, El}, StateData) ->
NewEl = jlib:remove_attr(<<"xmlns">>, El), NewEl = jlib:remove_attr(<<"xmlns">>, El),
#xmlel{name = Name, attrs = Attrs} = NewEl, #xmlel{name = Name, attrs = Attrs} = NewEl,
From_s = xml:get_attr_s(<<"from">>, Attrs), From_s = xml:get_attr_s(<<"from">>, Attrs),
From = jlib:string_to_jid(From_s), From = jid:from_string(From_s),
To_s = xml:get_attr_s(<<"to">>, Attrs), To_s = xml:get_attr_s(<<"to">>, Attrs),
To = jlib:string_to_jid(To_s), To = jid:from_string(To_s),
if (To /= error) and (From /= error) -> if (To /= error) and (From /= error) ->
LFrom = From#jid.lserver, LFrom = From#jid.lserver,
LTo = To#jid.lserver, LTo = To#jid.lserver,
@ -500,8 +500,8 @@ stream_established({valid, From, To}, StateData) ->
children = []}), children = []}),
?INFO_MSG("Accepted s2s dialback authentication for ~s (TLS=~p)", ?INFO_MSG("Accepted s2s dialback authentication for ~s (TLS=~p)",
[From, StateData#state.tls_enabled]), [From, StateData#state.tls_enabled]),
LFrom = jlib:nameprep(From), LFrom = jid:nameprep(From),
LTo = jlib:nameprep(To), LTo = jid:nameprep(To),
NSD = StateData#state{connections = NSD = StateData#state{connections =
(?DICT):store({LFrom, LTo}, established, (?DICT):store({LFrom, LTo}, established,
StateData#state.connections)}, StateData#state.connections)},
@ -513,8 +513,8 @@ stream_established({invalid, From, To}, StateData) ->
[{<<"from">>, To}, {<<"to">>, From}, [{<<"from">>, To}, {<<"to">>, From},
{<<"type">>, <<"invalid">>}], {<<"type">>, <<"invalid">>}],
children = []}), children = []}),
LFrom = jlib:nameprep(From), LFrom = jid:nameprep(From),
LTo = jlib:nameprep(To), LTo = jid:nameprep(To),
NSD = StateData#state{connections = NSD = StateData#state{connections =
(?DICT):erase({LFrom, LTo}, (?DICT):erase({LFrom, LTo},
StateData#state.connections)}, StateData#state.connections)},

View File

@ -999,9 +999,9 @@ bounce_element(El, Error) ->
<<"result">> -> ok; <<"result">> -> ok;
_ -> _ ->
Err = jlib:make_error_reply(El, Error), Err = jlib:make_error_reply(El, Error),
From = jlib:string_to_jid(xml:get_tag_attr_s(<<"from">>, From = jid:from_string(xml:get_tag_attr_s(<<"from">>,
El)), El)),
To = jlib:string_to_jid(xml:get_tag_attr_s(<<"to">>, To = jid:from_string(xml:get_tag_attr_s(<<"to">>,
El)), El)),
ejabberd_router:route(To, From, Err) ejabberd_router:route(To, From, Err)
end. end.

View File

@ -225,10 +225,10 @@ stream_established({xmlstreamelement, El}, StateData) ->
%% when accept packets from any address. %% when accept packets from any address.
%% In this case, the component can send packet of %% In this case, the component can send packet of
%% behalf of the server users. %% behalf of the server users.
false -> jlib:string_to_jid(From); false -> jid:from_string(From);
%% The default is the standard behaviour in XEP-0114 %% The default is the standard behaviour in XEP-0114
_ -> _ ->
FromJID1 = jlib:string_to_jid(From), FromJID1 = jid:from_string(From),
case FromJID1 of case FromJID1 of
#jid{lserver = Server} -> #jid{lserver = Server} ->
case lists:member(Server, StateData#state.hosts) of case lists:member(Server, StateData#state.hosts) of
@ -241,7 +241,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
To = xml:get_attr_s(<<"to">>, Attrs), To = xml:get_attr_s(<<"to">>, Attrs),
ToJID = case To of ToJID = case To of
<<"">> -> error; <<"">> -> error;
_ -> jlib:string_to_jid(To) _ -> jid:from_string(To)
end, end,
if ((Name == <<"iq">>) or (Name == <<"message">>) or if ((Name == <<"iq">>) or (Name == <<"message">>) or
(Name == <<"presence">>)) (Name == <<"presence">>))
@ -323,8 +323,8 @@ handle_info({route, From, To, Packet}, StateName,
#xmlel{name = Name, attrs = Attrs, children = Els} = #xmlel{name = Name, attrs = Attrs, children = Els} =
Packet, Packet,
Attrs2 = Attrs2 =
jlib:replace_from_to_attrs(jlib:jid_to_string(From), jlib:replace_from_to_attrs(jid:to_string(From),
jlib:jid_to_string(To), Attrs), jid:to_string(To), Attrs),
Text = xml:element_to_binary(#xmlel{name = Name, Text = xml:element_to_binary(#xmlel{name = Name,
attrs = Attrs2, children = Els}), attrs = Attrs2, children = Els}),
send_text(StateData, Text); send_text(StateData, Text);

View File

@ -120,7 +120,7 @@ route(From, To, Packet) ->
open_session(SID, User, Server, Resource, Priority, Info) -> open_session(SID, User, Server, Resource, Priority, Info) ->
set_session(SID, User, Server, Resource, Priority, Info), set_session(SID, User, Server, Resource, Priority, Info),
check_for_sessions_to_replace(User, Server, Resource), check_for_sessions_to_replace(User, Server, Resource),
JID = jlib:make_jid(User, Server, Resource), JID = jid:make(User, Server, Resource),
ejabberd_hooks:run(sm_register_connection_hook, ejabberd_hooks:run(sm_register_connection_hook,
JID#jid.lserver, [SID, JID, Info]). JID#jid.lserver, [SID, JID, Info]).
@ -133,14 +133,14 @@ open_session(SID, User, Server, Resource, Info) ->
close_session(SID, User, Server, Resource) -> close_session(SID, User, Server, Resource) ->
Mod = get_sm_backend(), Mod = get_sm_backend(),
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LResource = jlib:resourceprep(Resource), LResource = jid:resourceprep(Resource),
Info = case Mod:delete_session(LUser, LServer, LResource, SID) of Info = case Mod:delete_session(LUser, LServer, LResource, SID) of
{ok, #session{info = I}} -> I; {ok, #session{info = I}} -> I;
{error, notfound} -> [] {error, notfound} -> []
end, end,
JID = jlib:make_jid(User, Server, Resource), JID = jid:make(User, Server, Resource),
ejabberd_hooks:run(sm_remove_connection_hook, ejabberd_hooks:run(sm_remove_connection_hook,
JID#jid.lserver, [SID, JID, Info]). JID#jid.lserver, [SID, JID, Info]).
@ -164,13 +164,13 @@ bounce_offline_message(From, To, Packet) ->
-spec disconnect_removed_user(binary(), binary()) -> ok. -spec disconnect_removed_user(binary(), binary()) -> ok.
disconnect_removed_user(User, Server) -> disconnect_removed_user(User, Server) ->
ejabberd_sm:route(jlib:make_jid(<<"">>, <<"">>, <<"">>), ejabberd_sm:route(jid:make(<<"">>, <<"">>, <<"">>),
jlib:make_jid(User, Server, <<"">>), jid:make(User, Server, <<"">>),
{broadcast, {exit, <<"User removed">>}}). {broadcast, {exit, <<"User removed">>}}).
get_user_resources(User, Server) -> get_user_resources(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
Mod = get_sm_backend(), Mod = get_sm_backend(),
Ss = Mod:get_sessions(LUser, LServer), Ss = Mod:get_sessions(LUser, LServer),
[element(3, S#session.usr) || S <- clean_session_list(Ss)]. [element(3, S#session.usr) || S <- clean_session_list(Ss)].
@ -186,9 +186,9 @@ get_user_present_resources(LUser, LServer) ->
-spec get_user_ip(binary(), binary(), binary()) -> ip(). -spec get_user_ip(binary(), binary(), binary()) -> ip().
get_user_ip(User, Server, Resource) -> get_user_ip(User, Server, Resource) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LResource = jlib:resourceprep(Resource), LResource = jid:resourceprep(Resource),
Mod = get_sm_backend(), Mod = get_sm_backend(),
case Mod:get_sessions(LUser, LServer, LResource) of case Mod:get_sessions(LUser, LServer, LResource) of
[] -> [] ->
@ -201,9 +201,9 @@ get_user_ip(User, Server, Resource) ->
-spec get_user_info(binary(), binary(), binary()) -> info() | offline. -spec get_user_info(binary(), binary(), binary()) -> info() | offline.
get_user_info(User, Server, Resource) -> get_user_info(User, Server, Resource) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LResource = jlib:resourceprep(Resource), LResource = jid:resourceprep(Resource),
Mod = get_sm_backend(), Mod = get_sm_backend(),
case Mod:get_sessions(LUser, LServer, LResource) of case Mod:get_sessions(LUser, LServer, LResource) of
[] -> [] ->
@ -224,7 +224,7 @@ set_presence(SID, User, Server, Resource, Priority,
set_session(SID, User, Server, Resource, Priority, set_session(SID, User, Server, Resource, Priority,
Info), Info),
ejabberd_hooks:run(set_presence_hook, ejabberd_hooks:run(set_presence_hook,
jlib:nameprep(Server), jid:nameprep(Server),
[User, Server, Resource, Presence]). [User, Server, Resource, Presence]).
-spec unset_presence(sid(), binary(), binary(), -spec unset_presence(sid(), binary(), binary(),
@ -235,7 +235,7 @@ unset_presence(SID, User, Server, Resource, Status,
set_session(SID, User, Server, Resource, undefined, set_session(SID, User, Server, Resource, undefined,
Info), Info),
ejabberd_hooks:run(unset_presence_hook, ejabberd_hooks:run(unset_presence_hook,
jlib:nameprep(Server), jid:nameprep(Server),
[User, Server, Resource, Status]). [User, Server, Resource, Status]).
-spec close_session_unset_presence(sid(), binary(), binary(), -spec close_session_unset_presence(sid(), binary(), binary(),
@ -245,15 +245,15 @@ close_session_unset_presence(SID, User, Server,
Resource, Status) -> Resource, Status) ->
close_session(SID, User, Server, Resource), close_session(SID, User, Server, Resource),
ejabberd_hooks:run(unset_presence_hook, ejabberd_hooks:run(unset_presence_hook,
jlib:nameprep(Server), jid:nameprep(Server),
[User, Server, Resource, Status]). [User, Server, Resource, Status]).
-spec get_session_pid(binary(), binary(), binary()) -> none | pid(). -spec get_session_pid(binary(), binary(), binary()) -> none | pid().
get_session_pid(User, Server, Resource) -> get_session_pid(User, Server, Resource) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LResource = jlib:resourceprep(Resource), LResource = jid:resourceprep(Resource),
Mod = get_sm_backend(), Mod = get_sm_backend(),
case Mod:get_sessions(LUser, LServer, LResource) of case Mod:get_sessions(LUser, LServer, LResource) of
[#session{sid = {_, Pid}}] -> Pid; [#session{sid = {_, Pid}}] -> Pid;
@ -275,7 +275,7 @@ dirty_get_my_sessions_list() ->
-spec get_vh_session_list(binary()) -> [ljid()]. -spec get_vh_session_list(binary()) -> [ljid()].
get_vh_session_list(Server) -> get_vh_session_list(Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
Mod = get_sm_backend(), Mod = get_sm_backend(),
[S#session.usr || S <- Mod:get_sessions(LServer)]. [S#session.usr || S <- Mod:get_sessions(LServer)].
@ -288,7 +288,7 @@ get_all_pids() ->
-spec get_vh_session_number(binary()) -> non_neg_integer(). -spec get_vh_session_number(binary()) -> non_neg_integer().
get_vh_session_number(Server) -> get_vh_session_number(Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
Mod = get_sm_backend(), Mod = get_sm_backend(),
length(Mod:get_sessions(LServer)). length(Mod:get_sessions(LServer)).
@ -374,9 +374,9 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}.
prio(), info()) -> ok. prio(), info()) -> ok.
set_session(SID, User, Server, Resource, Priority, Info) -> set_session(SID, User, Server, Resource, Priority, Info) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LResource = jlib:resourceprep(Resource), LResource = jid:resourceprep(Resource),
US = {LUser, LServer}, US = {LUser, LServer},
USR = {LUser, LServer, LResource}, USR = {LUser, LServer, LResource},
Mod = get_sm_backend(), Mod = get_sm_backend(),
@ -390,12 +390,12 @@ do_route(From, To, {broadcast, _} = Packet) ->
<<"">> -> <<"">> ->
lists:foreach(fun(R) -> lists:foreach(fun(R) ->
do_route(From, do_route(From,
jlib:jid_replace_resource(To, R), jid:replace_resource(To, R),
Packet) Packet)
end, end,
get_user_resources(To#jid.user, To#jid.server)); get_user_resources(To#jid.user, To#jid.server));
_ -> _ ->
{U, S, R} = jlib:jid_tolower(To), {U, S, R} = jid:tolower(To),
Mod = get_sm_backend(), Mod = get_sm_backend(),
case Mod:get_sessions(U, S, R) of case Mod:get_sessions(U, S, R) of
[] -> [] ->
@ -474,7 +474,7 @@ do_route(From, To, #xmlel{} = Packet) ->
PResources = get_user_present_resources(LUser, LServer), PResources = get_user_present_resources(LUser, LServer),
lists:foreach(fun ({_, R}) -> lists:foreach(fun ({_, R}) ->
do_route(From, do_route(From,
jlib:jid_replace_resource(To, jid:replace_resource(To,
R), R),
Packet) Packet)
end, end,
@ -563,7 +563,7 @@ route_message(From, To, Packet, Type) ->
when is_integer(Priority), Priority >= 0 -> when is_integer(Priority), Priority >= 0 ->
lists:foreach(fun ({P, R}) when P == Priority; lists:foreach(fun ({P, R}) when P == Priority;
(P >= 0) and (Type == headline) -> (P >= 0) and (Type == headline) ->
LResource = jlib:resourceprep(R), LResource = jid:resourceprep(R),
Mod = get_sm_backend(), Mod = get_sm_backend(),
case Mod:get_sessions(LUser, LServer, case Mod:get_sessions(LUser, LServer,
LResource) of LResource) of
@ -619,9 +619,9 @@ clean_session_list([S1, S2 | Rest], Res) ->
%% On new session, check if some existing connections need to be replace %% On new session, check if some existing connections need to be replace
check_for_sessions_to_replace(User, Server, Resource) -> check_for_sessions_to_replace(User, Server, Resource) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LResource = jlib:resourceprep(Resource), LResource = jid:resourceprep(Resource),
check_existing_resources(LUser, LServer, LResource), check_existing_resources(LUser, LServer, LResource),
check_max_sessions(LUser, LServer). check_max_sessions(LUser, LServer).
@ -643,9 +643,9 @@ is_existing_resource(LUser, LServer, LResource) ->
[] /= get_resource_sessions(LUser, LServer, LResource). [] /= get_resource_sessions(LUser, LServer, LResource).
get_resource_sessions(User, Server, Resource) -> get_resource_sessions(User, Server, Resource) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LResource = jlib:resourceprep(Resource), LResource = jid:resourceprep(Resource),
Mod = get_sm_backend(), Mod = get_sm_backend(),
[S#session.sid || S <- Mod:get_sessions(LUser, LServer, LResource)]. [S#session.sid || S <- Mod:get_sessions(LUser, LServer, LResource)].
@ -663,7 +663,7 @@ check_max_sessions(LUser, LServer) ->
%% Defaults to infinity %% Defaults to infinity
get_max_user_sessions(LUser, Host) -> get_max_user_sessions(LUser, Host) ->
case acl:match_rule(Host, max_user_sessions, case acl:match_rule(Host, max_user_sessions,
jlib:make_jid(LUser, Host, <<"">>)) jid:make(LUser, Host, <<"">>))
of of
Max when is_integer(Max) -> Max; Max when is_integer(Max) -> Max;
infinity -> infinity; infinity -> infinity;

View File

@ -68,7 +68,7 @@ process_command(From, To, Packet) ->
case Name of case Name of
<<"message">> -> <<"message">> ->
LFrom = LFrom =
jlib:jid_tolower(jlib:jid_remove_resource(From)), jid:tolower(jid:remove_resource(From)),
case lists:member(LFrom, get_admin_jids()) of case lists:member(LFrom, get_admin_jids()) of
true -> true ->
Body = xml:get_path_s(Packet, Body = xml:get_path_s(Packet,
@ -185,9 +185,9 @@ process_large_heap(Pid, Info) ->
io_lib: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 = jlib:make_jid(<<"">>, Host, <<"watchdog">>), From = jid:make(<<"">>, Host, <<"watchdog">>),
lists:foreach(fun (JID) -> lists:foreach(fun (JID) ->
send_message(From, jlib:make_jid(JID), Body) send_message(From, jid:make(JID), Body)
end, JIDs). end, JIDs).
send_message(From, To, Body) -> send_message(From, To, Body) ->
@ -203,8 +203,8 @@ get_admin_jids() ->
ejabberd_config:get_option( ejabberd_config:get_option(
watchdog_admins, watchdog_admins,
fun(JIDs) -> fun(JIDs) ->
[jlib:jid_tolower( [jid:tolower(
jlib:string_to_jid( jid:from_string(
iolist_to_binary(S))) || S <- JIDs] iolist_to_binary(S))) || S <- JIDs]
end, []). end, []).
@ -336,7 +336,7 @@ process_remote_command(_) -> throw(unknown_command).
opt_type(watchdog_admins) -> opt_type(watchdog_admins) ->
fun (JIDs) -> fun (JIDs) ->
[jlib:jid_tolower(jlib:string_to_jid(iolist_to_binary(S))) [jid:tolower(jid:from_string(iolist_to_binary(S)))
|| S <- JIDs] || S <- JIDs]
end; end;
opt_type(watchdog_large_heap) -> opt_type(watchdog_large_heap) ->

View File

@ -95,7 +95,7 @@ is_acl_match(Host, Rules, Jid) ->
get_jid(Auth, HostHTTP, Method) -> get_jid(Auth, HostHTTP, Method) ->
case get_auth_admin(Auth, HostHTTP, [], Method) of case get_auth_admin(Auth, HostHTTP, [], Method) of
{ok, {User, Server}} -> {ok, {User, Server}} ->
jlib:make_jid(User, Server, <<"">>); jid:make(User, Server, <<"">>);
{unauthorized, Error} -> {unauthorized, Error} ->
?ERROR_MSG("Unauthorized ~p: ~p", [Auth, Error]), ?ERROR_MSG("Unauthorized ~p: ~p", [Auth, Error]),
throw({unauthorized, Auth}) throw({unauthorized, Auth})
@ -184,7 +184,7 @@ process([<<"server">>, SHost | RPath] = Path,
#request{auth = Auth, lang = Lang, host = HostHTTP, #request{auth = Auth, lang = Lang, host = HostHTTP,
method = Method} = method = Method} =
Request) -> Request) ->
Host = jlib:nameprep(SHost), Host = jid:nameprep(SHost),
case lists:member(Host, ?MYHOSTS) of case lists:member(Host, ?MYHOSTS) of
true -> true ->
case get_auth_admin(Auth, HostHTTP, Path, Method) of case get_auth_admin(Auth, HostHTTP, Path, Method) of
@ -250,7 +250,7 @@ get_auth_admin(Auth, HostHTTP, RPath, Method) ->
case Auth of case Auth of
{SJID, Pass} -> {SJID, Pass} ->
{HostOfRule, AccessRule} = get_acl_rule(RPath, Method), {HostOfRule, AccessRule} = get_acl_rule(RPath, Method),
case jlib:string_to_jid(SJID) of case jid:from_string(SJID) of
error -> {unauthorized, <<"badformed-jid">>}; error -> {unauthorized, <<"badformed-jid">>};
#jid{user = <<"">>, server = User} -> #jid{user = <<"">>, server = User} ->
get_auth_account(HostOfRule, AccessRule, User, HostHTTP, get_auth_account(HostOfRule, AccessRule, User, HostHTTP,
@ -267,7 +267,7 @@ get_auth_account(HostOfRule, AccessRule, User, Server,
case ejabberd_auth:check_password(User, Server, Pass) of case ejabberd_auth:check_password(User, Server, Pass) of
true -> true ->
case is_acl_match(HostOfRule, AccessRule, case is_acl_match(HostOfRule, AccessRule,
jlib:make_jid(User, Server, <<"">>)) jid:make(User, Server, <<"">>))
of of
false -> {unauthorized, <<"unprivileged-account">>}; false -> {unauthorized, <<"unprivileged-account">>};
true -> {ok, {User, Server}} true -> {ok, {User, Server}}
@ -1128,7 +1128,7 @@ string_to_spec(<<"server_regexp">>, Val) ->
{server_regexp, Val}; {server_regexp, Val};
string_to_spec(<<"node_regexp">>, Val) -> string_to_spec(<<"node_regexp">>, Val) ->
#jid{luser = U, lserver = S, resource = <<"">>} = #jid{luser = U, lserver = S, resource = <<"">>} =
jlib:string_to_jid(Val), jid:from_string(Val),
{node_regexp, U, S}; {node_regexp, U, S};
string_to_spec(<<"user_glob">>, Val) -> string_to_spec(<<"user_glob">>, Val) ->
string_to_spec2(user_glob, Val); string_to_spec2(user_glob, Val);
@ -1136,7 +1136,7 @@ string_to_spec(<<"server_glob">>, Val) ->
{server_glob, Val}; {server_glob, Val};
string_to_spec(<<"node_glob">>, Val) -> string_to_spec(<<"node_glob">>, Val) ->
#jid{luser = U, lserver = S, resource = <<"">>} = #jid{luser = U, lserver = S, resource = <<"">>} =
jlib:string_to_jid(Val), jid:from_string(Val),
{node_glob, U, S}; {node_glob, U, S};
string_to_spec(<<"all">>, _) -> all; string_to_spec(<<"all">>, _) -> all;
string_to_spec(<<"raw">>, Val) -> string_to_spec(<<"raw">>, Val) ->
@ -1146,7 +1146,7 @@ string_to_spec(<<"raw">>, Val) ->
string_to_spec2(ACLName, Val) -> string_to_spec2(ACLName, Val) ->
#jid{luser = U, lserver = S, resource = <<"">>} = #jid{luser = U, lserver = S, resource = <<"">>} =
jlib:string_to_jid(Val), jid:from_string(Val),
case U of case U of
<<"">> -> {ACLName, S}; <<"">> -> {ACLName, S};
_ -> {ACLName, {U, S}} _ -> {ACLName, {U, S}}
@ -1362,7 +1362,7 @@ list_users_parse_query(Query, Host) ->
lists:keysearch(<<"newusername">>, 1, Query), lists:keysearch(<<"newusername">>, 1, Query),
{value, {_, Password}} = {value, {_, Password}} =
lists:keysearch(<<"newuserpassword">>, 1, Query), lists:keysearch(<<"newuserpassword">>, 1, Query),
case jlib:string_to_jid(<<Username/binary, "@", case jid:from_string(<<Username/binary, "@",
Host/binary>>) Host/binary>>)
of of
error -> error; error -> error;
@ -1463,10 +1463,10 @@ get_lastactivity_menuitem_list(Server) ->
end. end.
us_to_list({User, Server}) -> us_to_list({User, Server}) ->
jlib:jid_to_string({User, Server, <<"">>}). jid:to_string({User, Server, <<"">>}).
su_to_list({Server, User}) -> su_to_list({Server, User}) ->
jlib:jid_to_string({User, Server, <<"">>}). jid:to_string({User, Server, <<"">>}).
%%%================================== %%%==================================
%%%% get_stats %%%% get_stats
@ -1521,8 +1521,8 @@ list_online_users(Host, _Lang) ->
SUsers). SUsers).
user_info(User, Server, Query, Lang) -> user_info(User, Server, Query, Lang) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {jlib:nodeprep(User), LServer}, US = {jid:nodeprep(User), LServer},
Res = user_parse_query(User, Server, Query), Res = user_parse_query(User, Server, Query),
Resources = ejabberd_sm:get_user_resources(User, Resources = ejabberd_sm:get_user_resources(User,
Server), Server),

View File

@ -62,7 +62,7 @@ modules() ->
mod_vcard_xupdate]. mod_vcard_xupdate].
export(Server, Output) -> export(Server, Output) ->
LServer = jlib:nameprep(iolist_to_binary(Server)), LServer = jid:nameprep(iolist_to_binary(Server)),
Modules = modules(), Modules = modules(),
IO = prepare_output(Output), IO = prepare_output(Output),
lists:foreach( lists:foreach(
@ -72,7 +72,7 @@ export(Server, Output) ->
close_output(Output, IO). close_output(Output, IO).
export(Server, Output, Module) -> export(Server, Output, Module) ->
LServer = jlib:nameprep(iolist_to_binary(Server)), LServer = jid:nameprep(iolist_to_binary(Server)),
IO = prepare_output(Output), IO = prepare_output(Output),
lists:foreach( lists:foreach(
fun({Table, ConvertFun}) -> fun({Table, ConvertFun}) ->
@ -87,7 +87,7 @@ import_file(Server, FileName) ->
{file, FileName}, {file, FileName},
{mode, read_only}]) of {mode, read_only}]) of
{ok, Fd} -> {ok, Fd} ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
Mods = [{Mod, gen_mod:db_type(LServer, Mod)} Mods = [{Mod, gen_mod:db_type(LServer, Mod)}
|| Mod <- modules(), gen_mod:is_loaded(LServer, Mod)], || Mod <- modules(), gen_mod:is_loaded(LServer, Mod)],
AuthMods = case lists:member(ejabberd_auth_internal, AuthMods = case lists:member(ejabberd_auth_internal,
@ -106,7 +106,7 @@ import(Server, Output) ->
import(Server, Output, [{fast, true}]). import(Server, Output, [{fast, true}]).
import(Server, Output, Opts) -> import(Server, Output, Opts) ->
LServer = jlib:nameprep(iolist_to_binary(Server)), LServer = jid:nameprep(iolist_to_binary(Server)),
Modules = modules(), Modules = modules(),
IO = prepare_output(Output, disk_log), IO = prepare_output(Output, disk_log),
lists:foreach( lists:foreach(
@ -116,7 +116,7 @@ import(Server, Output, Opts) ->
close_output(Output, IO). close_output(Output, IO).
import(Server, Output, Opts, Module) -> import(Server, Output, Opts, Module) ->
LServer = jlib:nameprep(iolist_to_binary(Server)), LServer = jid:nameprep(iolist_to_binary(Server)),
IO = prepare_output(Output, disk_log), IO = prepare_output(Output, disk_log),
lists:foreach( lists:foreach(
fun({SelectQuery, ConvertFun}) -> fun({SelectQuery, ConvertFun}) ->

View File

@ -95,7 +95,7 @@ remove_user(User, Server, Password) ->
[<<"removeuser3">>, User, Server, Password]). [<<"removeuser3">>, User, Server, Password]).
call_port(Server, Msg) -> call_port(Server, Msg) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
ProcessName = get_process_name(LServer, ProcessName = get_process_name(LServer,
random_instance(get_instances(LServer))), random_instance(get_instances(LServer))),
ProcessName ! {call, self(), Msg}, ProcessName ! {call, self(), Msg},

View File

@ -42,8 +42,8 @@
import_file(File) -> import_file(File) ->
User = filename:rootname(filename:basename(File)), User = filename:rootname(filename:basename(File)),
Server = filename:basename(filename:dirname(File)), Server = filename:basename(filename:dirname(File)),
case jlib:nodeprep(User) /= error andalso case jid:nodeprep(User) /= error andalso
jlib:nameprep(Server) /= error jid:nameprep(Server) /= error
of of
true -> true ->
case file:read_file(File) of case file:read_file(File) of
@ -112,7 +112,7 @@ process_xdb(User, Server,
xdb_data(_User, _Server, {xmlcdata, _CData}) -> ok; xdb_data(_User, _Server, {xmlcdata, _CData}) -> ok;
xdb_data(User, Server, #xmlel{attrs = Attrs} = El) -> xdb_data(User, Server, #xmlel{attrs = Attrs} = El) ->
From = jlib:make_jid(User, Server, <<"">>), From = jid:make(User, Server, <<"">>),
case xml:get_attr_s(<<"xmlns">>, Attrs) of case xml:get_attr_s(<<"xmlns">>, Attrs) of
?NS_AUTH -> ?NS_AUTH ->
Password = xml:get_tag_cdata(El), Password = xml:get_tag_cdata(El),
@ -129,7 +129,7 @@ xdb_data(User, Server, #xmlel{attrs = Attrs} = El) ->
ok; ok;
?NS_VCARD -> ?NS_VCARD ->
catch mod_vcard:process_sm_iq(From, catch mod_vcard:process_sm_iq(From,
jlib:make_jid(<<"">>, Server, <<"">>), jid:make(<<"">>, Server, <<"">>),
#iq{type = set, xmlns = ?NS_VCARD, #iq{type = set, xmlns = ?NS_VCARD,
sub_el = El}), sub_el = El}),
ok; ok;
@ -139,7 +139,7 @@ xdb_data(User, Server, #xmlel{attrs = Attrs} = El) ->
case xml:get_attr_s(<<"j_private_flag">>, Attrs) of case xml:get_attr_s(<<"j_private_flag">>, Attrs) of
<<"1">> -> <<"1">> ->
catch mod_private:process_sm_iq(From, catch mod_private:process_sm_iq(From,
jlib:make_jid(<<"">>, Server, jid:make(<<"">>, Server,
<<"">>), <<"">>),
#iq{type = set, #iq{type = set,
xmlns = ?NS_PRIVATE, xmlns = ?NS_PRIVATE,
@ -158,13 +158,13 @@ xdb_data(User, Server, #xmlel{attrs = Attrs} = El) ->
end. end.
process_offline(Server, To, #xmlel{children = Els}) -> process_offline(Server, To, #xmlel{children = Els}) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
lists:foreach(fun (#xmlel{attrs = Attrs} = El) -> lists:foreach(fun (#xmlel{attrs = Attrs} = El) ->
FromS = xml:get_attr_s(<<"from">>, Attrs), FromS = xml:get_attr_s(<<"from">>, Attrs),
From = case FromS of From = case FromS of
<<"">> -> <<"">> ->
jlib:make_jid(<<"">>, Server, <<"">>); jid:make(<<"">>, Server, <<"">>);
_ -> jlib:string_to_jid(FromS) _ -> jid:from_string(FromS)
end, end,
case From of case From of
error -> ok; error -> ok;

228
src/jid.erl Normal file
View File

@ -0,0 +1,228 @@
%%%-------------------------------------------------------------------
%%% @author Evgeny Khramtsov <ekhramtsov@process-one.net>
%%% @doc
%%% JID processing library
%%% @end
%%% Created : 24 Nov 2015 by Evgeny Khramtsov <ekhramtsov@process-one.net>
%%%
%%%
%%% ejabberd, Copyright (C) 2002-2015 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License along
%%% with this program; if not, write to the Free Software Foundation, Inc.,
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
%%%
%%%-------------------------------------------------------------------
-module(jid).
%% API
-export([start/0,
make/1,
make/3,
split/1,
from_string/1,
to_string/1,
is_nodename/1,
nodeprep/1,
nameprep/1,
resourceprep/1,
tolower/1,
remove_resource/1,
replace_resource/2]).
-include("jlib.hrl").
-export_type([jid/0]).
%%%===================================================================
%%% API
%%%===================================================================
-spec start() -> ok.
start() ->
SplitPattern = binary:compile_pattern([<<"@">>, <<"/">>]),
catch ets:new(jlib, [named_table, protected, set, {keypos, 1}]),
ets:insert(jlib, {string_to_jid_pattern, SplitPattern}),
ok.
-spec make(binary(), binary(), binary()) -> jid() | error.
make(User, Server, Resource) ->
case nodeprep(User) of
error -> error;
LUser ->
case nameprep(Server) of
error -> error;
LServer ->
case resourceprep(Resource) of
error -> error;
LResource ->
#jid{user = User, server = Server, resource = Resource,
luser = LUser, lserver = LServer,
lresource = LResource}
end
end
end.
-spec make({binary(), binary(), binary()}) -> jid() | error.
make({User, Server, Resource}) ->
make(User, Server, Resource).
%% This is the reverse of make_jid/1
-spec split(jid()) -> {binary(), binary(), binary()} | error.
split(#jid{user = U, server = S, resource = R}) ->
{U, S, R};
split(_) ->
error.
-spec from_string(binary()) -> jid() | error.
from_string(S) ->
SplitPattern = ets:lookup_element(jlib, string_to_jid_pattern, 2),
Size = size(S),
End = Size-1,
case binary:match(S, SplitPattern) of
{0, _} ->
error;
{End, _} ->
error;
{Pos1, _} ->
case binary:at(S, Pos1) of
$/ ->
make(<<>>,
binary:part(S, 0, Pos1),
binary:part(S, Pos1+1, Size-Pos1-1));
_ ->
Pos1N = Pos1+1,
case binary:match(S, SplitPattern, [{scope, {Pos1+1, Size-Pos1-1}}]) of
{End, _} ->
error;
{Pos1N, _} ->
error;
{Pos2, _} ->
case binary:at(S, Pos2) of
$/ ->
make(binary:part(S, 0, Pos1),
binary:part(S, Pos1+1, Pos2-Pos1-1),
binary:part(S, Pos2+1, Size-Pos2-1));
_ -> error
end;
_ ->
make(binary:part(S, 0, Pos1),
binary:part(S, Pos1+1, Size-Pos1-1),
<<>>)
end
end;
_ ->
make(<<>>, S, <<>>)
end.
-spec to_string(jid() | ljid()) -> binary().
to_string(#jid{user = User, server = Server,
resource = Resource}) ->
to_string({User, Server, Resource});
to_string({N, S, R}) ->
Node = iolist_to_binary(N),
Server = iolist_to_binary(S),
Resource = iolist_to_binary(R),
S1 = case Node of
<<"">> -> <<"">>;
_ -> <<Node/binary, "@">>
end,
S2 = <<S1/binary, Server/binary>>,
S3 = case Resource of
<<"">> -> S2;
_ -> <<S2/binary, "/", Resource/binary>>
end,
S3.
-spec is_nodename(binary()) -> boolean().
is_nodename(Node) ->
N = nodeprep(Node),
(N /= error) and (N /= <<>>).
-define(LOWER(Char),
if Char >= $A, Char =< $Z -> Char + 32;
true -> Char
end).
-spec nodeprep(binary()) -> binary() | error.
nodeprep("") -> <<>>;
nodeprep(S) when byte_size(S) < 1024 ->
R = stringprep:nodeprep(S),
if byte_size(R) < 1024 -> R;
true -> error
end;
nodeprep(_) -> error.
-spec nameprep(binary()) -> binary() | error.
nameprep(S) when byte_size(S) < 1024 ->
R = stringprep:nameprep(S),
if byte_size(R) < 1024 -> R;
true -> error
end;
nameprep(_) -> error.
-spec resourceprep(binary()) -> binary() | error.
resourceprep(S) when byte_size(S) < 1024 ->
R = stringprep:resourceprep(S),
if byte_size(R) < 1024 -> R;
true -> error
end;
resourceprep(_) -> error.
-spec tolower(jid() | ljid()) -> error | ljid().
tolower(#jid{luser = U, lserver = S,
lresource = R}) ->
{U, S, R};
tolower({U, S, R}) ->
case nodeprep(U) of
error -> error;
LUser ->
case nameprep(S) of
error -> error;
LServer ->
case resourceprep(R) of
error -> error;
LResource -> {LUser, LServer, LResource}
end
end
end.
-spec remove_resource(jid()) -> jid();
(ljid()) -> ljid().
remove_resource(#jid{} = JID) ->
JID#jid{resource = <<"">>, lresource = <<"">>};
remove_resource({U, S, _R}) -> {U, S, <<"">>}.
-spec replace_resource(jid(), binary()) -> error | jid().
replace_resource(JID, Resource) ->
case resourceprep(Resource) of
error -> error;
LResource ->
JID#jid{resource = Resource, lresource = LResource}
end.
%%%===================================================================
%%% Internal functions
%%%===================================================================

View File

@ -39,10 +39,7 @@
make_error_reply/2, make_error_element/2, make_error_reply/2, make_error_element/2,
make_correct_from_to_attrs/3, replace_from_to_attrs/3, make_correct_from_to_attrs/3, replace_from_to_attrs/3,
replace_from_to/3, replace_from_attrs/2, replace_from/2, replace_from_to/3, replace_from_attrs/2, replace_from/2,
remove_attr/2, make_jid/3, make_jid/1, split_jid/1, string_to_jid/1, remove_attr/2, tolower/1,
jid_to_string/1, is_nodename/1, tolower/1, nodeprep/1,
nameprep/1, resourceprep/1, jid_tolower/1,
jid_remove_resource/1, jid_replace_resource/2,
get_iq_namespace/1, iq_query_info/1, get_iq_namespace/1, iq_query_info/1,
iq_query_or_response_info/1, is_iq_request_type/1, iq_query_or_response_info/1, is_iq_request_type/1,
iq_to_xml/1, parse_xdata_submit/1, iq_to_xml/1, parse_xdata_submit/1,
@ -58,19 +55,16 @@
atom_to_binary/1, binary_to_atom/1, tuple_to_binary/1, atom_to_binary/1, binary_to_atom/1, tuple_to_binary/1,
l2i/1, i2l/1, i2l/2, queue_drop_while/2]). l2i/1, i2l/1, i2l/2, queue_drop_while/2]).
-export([start/0]). %% The following functions are deprecated and will be removed soon
%% Use corresponding functions from jid.erl instead
-export([make_jid/3, make_jid/1, split_jid/1, string_to_jid/1,
jid_to_string/1, is_nodename/1, nodeprep/1,
nameprep/1, resourceprep/1, jid_tolower/1,
jid_remove_resource/1, jid_replace_resource/2]).
-include("ejabberd.hrl"). -include("ejabberd.hrl").
-include("jlib.hrl"). -include("jlib.hrl").
-export_type([jid/0]).
start() ->
SplitPattern = binary:compile_pattern([<<"@">>, <<"/">>]),
catch ets:new(jlib, [named_table, protected, set, {keypos, 1}]),
ets:insert(jlib, {string_to_jid_pattern, SplitPattern}),
ok.
%send_iq(From, To, ID, SubTags) -> %send_iq(From, To, ID, SubTags) ->
% ok. % ok.
@ -173,8 +167,8 @@ replace_from_to_attrs(From, To, Attrs) ->
replace_from_to(From, To, replace_from_to(From, To,
#xmlel{name = Name, attrs = Attrs, children = Els}) -> #xmlel{name = Name, attrs = Attrs, children = Els}) ->
NewAttrs = NewAttrs =
replace_from_to_attrs(jlib:jid_to_string(From), replace_from_to_attrs(jid:to_string(From),
jlib:jid_to_string(To), Attrs), jid:to_string(To), Attrs),
#xmlel{name = Name, attrs = NewAttrs, children = Els}. #xmlel{name = Name, attrs = NewAttrs, children = Els}.
-spec replace_from_attrs(binary(), [attr()]) -> [attr()]. -spec replace_from_attrs(binary(), [attr()]) -> [attr()].
@ -187,7 +181,7 @@ replace_from_attrs(From, Attrs) ->
replace_from(From, replace_from(From,
#xmlel{name = Name, attrs = Attrs, children = Els}) -> #xmlel{name = Name, attrs = Attrs, children = Els}) ->
NewAttrs = replace_from_attrs(jlib:jid_to_string(From), NewAttrs = replace_from_attrs(jid:to_string(From),
Attrs), Attrs),
#xmlel{name = Name, attrs = NewAttrs, children = Els}. #xmlel{name = Name, attrs = NewAttrs, children = Els}.
@ -201,101 +195,32 @@ remove_attr(Attr,
-spec make_jid(binary(), binary(), binary()) -> jid() | error. -spec make_jid(binary(), binary(), binary()) -> jid() | error.
make_jid(User, Server, Resource) -> make_jid(User, Server, Resource) ->
case nodeprep(User) of jid:make(User, Server, Resource).
error -> error;
LUser ->
case nameprep(Server) of
error -> error;
LServer ->
case resourceprep(Resource) of
error -> error;
LResource ->
#jid{user = User, server = Server, resource = Resource,
luser = LUser, lserver = LServer,
lresource = LResource}
end
end
end.
-spec make_jid({binary(), binary(), binary()}) -> jid() | error. -spec make_jid({binary(), binary(), binary()}) -> jid() | error.
make_jid({User, Server, Resource}) -> make_jid({User, Server, Resource}) ->
make_jid(User, Server, Resource). jid:make({User, Server, Resource}).
%% This is the reverse of make_jid/1 %% This is the reverse of make_jid/1
-spec split_jid(jid()) -> {binary(), binary(), binary()} | error. -spec split_jid(jid()) -> {binary(), binary(), binary()} | error.
split_jid(#jid{user = U, server = S, resource = R}) -> split_jid(J) ->
{U, S, R}; jid:split(J).
split_jid(_) ->
error.
-spec string_to_jid(binary()) -> jid() | error. -spec string_to_jid(binary()) -> jid() | error.
string_to_jid(S) -> string_to_jid(S) ->
SplitPattern = ets:lookup_element(jlib, string_to_jid_pattern, 2), jid:from_string(S).
Size = size(S),
End = Size-1,
case binary:match(S, SplitPattern) of
{0, _} ->
error;
{End, _} ->
error;
{Pos1, _} ->
case binary:at(S, Pos1) of
$/ ->
make_jid(<<>>,
binary:part(S, 0, Pos1),
binary:part(S, Pos1+1, Size-Pos1-1));
_ ->
Pos1N = Pos1+1,
case binary:match(S, SplitPattern, [{scope, {Pos1+1, Size-Pos1-1}}]) of
{End, _} ->
error;
{Pos1N, _} ->
error;
{Pos2, _} ->
case binary:at(S, Pos2) of
$/ ->
make_jid(binary:part(S, 0, Pos1),
binary:part(S, Pos1+1, Pos2-Pos1-1),
binary:part(S, Pos2+1, Size-Pos2-1));
_ -> error
end;
_ ->
make_jid(binary:part(S, 0, Pos1),
binary:part(S, Pos1+1, Size-Pos1-1),
<<>>)
end
end;
_ ->
make_jid(<<>>, S, <<>>)
end.
-spec jid_to_string(jid() | ljid()) -> binary(). -spec jid_to_string(jid() | ljid()) -> binary().
jid_to_string(#jid{user = User, server = Server, jid_to_string(J) ->
resource = Resource}) -> jid:to_string(J).
jid_to_string({User, Server, Resource});
jid_to_string({N, S, R}) ->
Node = iolist_to_binary(N),
Server = iolist_to_binary(S),
Resource = iolist_to_binary(R),
S1 = case Node of
<<"">> -> <<"">>;
_ -> <<Node/binary, "@">>
end,
S2 = <<S1/binary, Server/binary>>,
S3 = case Resource of
<<"">> -> S2;
_ -> <<S2/binary, "/", Resource/binary>>
end,
S3.
-spec is_nodename(binary()) -> boolean(). -spec is_nodename(binary()) -> boolean().
is_nodename(Node) -> is_nodename(Node) ->
N = nodeprep(Node), jid:is_nodename(Node).
(N /= error) and (N /= <<>>).
%tolower_c(C) when C >= $A, C =< $Z -> %tolower_c(C) when C >= $A, C =< $Z ->
% C + 32; % C + 32;
@ -333,66 +258,30 @@ tolower_s([]) -> [].
-spec nodeprep(binary()) -> binary() | error. -spec nodeprep(binary()) -> binary() | error.
nodeprep("") -> <<>>; nodeprep(S) -> jid:nodeprep(S).
nodeprep(S) when byte_size(S) < 1024 ->
R = stringprep:nodeprep(S),
if byte_size(R) < 1024 -> R;
true -> error
end;
nodeprep(_) -> error.
-spec nameprep(binary()) -> binary() | error. -spec nameprep(binary()) -> binary() | error.
nameprep(S) when byte_size(S) < 1024 -> nameprep(S) -> jid:nameprep(S).
R = stringprep:nameprep(S),
if byte_size(R) < 1024 -> R;
true -> error
end;
nameprep(_) -> error.
-spec resourceprep(binary()) -> binary() | error. -spec resourceprep(binary()) -> binary() | error.
resourceprep(S) when byte_size(S) < 1024 -> resourceprep(S) -> jid:resourceprep(S).
R = stringprep:resourceprep(S),
if byte_size(R) < 1024 -> R;
true -> error
end;
resourceprep(_) -> error.
-spec jid_tolower(jid() | ljid()) -> error | ljid(). -spec jid_tolower(jid() | ljid()) -> error | ljid().
jid_tolower(#jid{luser = U, lserver = S, jid_tolower(J) ->
lresource = R}) -> jid:tolower(J).
{U, S, R};
jid_tolower({U, S, R}) ->
case nodeprep(U) of
error -> error;
LUser ->
case nameprep(S) of
error -> error;
LServer ->
case resourceprep(R) of
error -> error;
LResource -> {LUser, LServer, LResource}
end
end
end.
-spec jid_remove_resource(jid()) -> jid(); -spec jid_remove_resource(jid()) -> jid();
(ljid()) -> ljid(). (ljid()) -> ljid().
jid_remove_resource(#jid{} = JID) -> jid_remove_resource(J) -> jid:remove_resource(J).
JID#jid{resource = <<"">>, lresource = <<"">>};
jid_remove_resource({U, S, _R}) -> {U, S, <<"">>}.
-spec jid_replace_resource(jid(), binary()) -> error | jid(). -spec jid_replace_resource(jid(), binary()) -> error | jid().
jid_replace_resource(JID, Resource) -> jid_replace_resource(JID, Resource) ->
case resourceprep(Resource) of jid:replace_resource(JID, Resource).
error -> error;
LResource ->
JID#jid{resource = Resource, lresource = LResource}
end.
-spec get_iq_namespace(xmlel()) -> binary(). -spec get_iq_namespace(xmlel()) -> binary().
@ -668,7 +557,7 @@ add_delay_info(El, From, Time, Desc) ->
-> xmlel() | error. -> xmlel() | error.
create_delay_tag(TimeStamp, FromJID, Desc) when is_tuple(FromJID) -> create_delay_tag(TimeStamp, FromJID, Desc) when is_tuple(FromJID) ->
From = jlib:jid_to_string(FromJID), From = jid:to_string(FromJID),
Stamp = now_to_utc_string(TimeStamp, 3), Stamp = now_to_utc_string(TimeStamp, 3),
Children = case Desc of Children = case Desc of
<<"">> -> []; <<"">> -> [];
@ -680,7 +569,7 @@ create_delay_tag(TimeStamp, FromJID, Desc) when is_tuple(FromJID) ->
{<<"stamp">>, Stamp}], {<<"stamp">>, Stamp}],
children = Children}; children = Children};
create_delay_tag(DateTime, Host, Desc) when is_binary(Host) -> create_delay_tag(DateTime, Host, Desc) when is_binary(Host) ->
FromJID = jlib:make_jid(<<"">>, Host, <<"">>), FromJID = jid:make(<<"">>, Host, <<"">>),
create_delay_tag(DateTime, FromJID, Desc). create_delay_tag(DateTime, FromJID, Desc).
-type tz() :: {binary(), {integer(), integer()}} | {integer(), integer()} | utc. -type tz() :: {binary(), {integer(), integer()}} | {integer(), integer()} | utc.

View File

@ -142,7 +142,7 @@ get_sm_commands(Acc, _From,
end, end,
Nodes = [#xmlel{name = <<"item">>, Nodes = [#xmlel{name = <<"item">>,
attrs = attrs =
[{<<"jid">>, jlib:jid_to_string(To)}, [{<<"jid">>, jid:to_string(To)},
{<<"node">>, ?NS_COMMANDS}, {<<"node">>, ?NS_COMMANDS},
{<<"name">>, {<<"name">>,
translate:translate(Lang, <<"Commands">>)}], translate:translate(Lang, <<"Commands">>)}],

View File

@ -688,8 +688,8 @@ get_resources(User, Server) ->
get_sessions(User, Server)). get_sessions(User, Server)).
get_sessions(User, Server) -> get_sessions(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
Sessions = mnesia:dirty_index_read(session, {LUser, LServer}, #session.us), Sessions = mnesia:dirty_index_read(session, {LUser, LServer}, #session.us),
true = is_list(Sessions), true = is_list(Sessions),
Sessions. Sessions.
@ -734,8 +734,8 @@ kick_session(User, Server, Resource, ReasonText) ->
ok. ok.
kick_this_session(User, Server, Resource, Reason) -> kick_this_session(User, Server, Resource, Reason) ->
ejabberd_sm:route(jlib:make_jid(<<"">>, <<"">>, <<"">>), ejabberd_sm:route(jid:make(<<"">>, <<"">>, <<"">>),
jlib:make_jid(User, Server, Resource), jid:make(User, Server, Resource),
{broadcast, {exit, Reason}}). {broadcast, {exit, Reason}}).
status_num(Host, Status) -> status_num(Host, Status) ->
@ -814,8 +814,8 @@ stringize(String) ->
set_presence(User, Host, Resource, Type, Show, Status, Priority) -> set_presence(User, Host, Resource, Type, Show, Status, Priority) ->
Pid = ejabberd_sm:get_session_pid(User, Host, Resource), Pid = ejabberd_sm:get_session_pid(User, Host, Resource),
USR = jlib:jid_to_string(jlib:make_jid(User, Host, Resource)), USR = jid:to_string(jid:make(User, Host, Resource)),
US = jlib:jid_to_string(jlib:make_jid(User, Host, <<>>)), US = jid:to_string(jid:make(User, Host, <<>>)),
Message = {route_xmlstreamelement, Message = {route_xmlstreamelement,
{xmlel, <<"presence">>, {xmlel, <<"presence">>,
[{<<"from">>, USR}, {<<"to">>, US}, {<<"type">>, Type}], [{<<"from">>, USR}, {<<"to">>, US}, {<<"type">>, Type}],
@ -901,7 +901,7 @@ get_module_resource(Server) ->
get_vcard_content(User, Server, Data) -> get_vcard_content(User, Server, Data) ->
[{_, Module, Function, _Opts}] = ets:lookup(sm_iqtable, {?NS_VCARD, Server}), [{_, Module, Function, _Opts}] = ets:lookup(sm_iqtable, {?NS_VCARD, Server}),
JID = jlib:make_jid(User, Server, get_module_resource(Server)), JID = jid:make(User, Server, get_module_resource(Server)),
IQ = #iq{type = get, xmlns = ?NS_VCARD}, IQ = #iq{type = get, xmlns = ?NS_VCARD},
IQr = Module:Function(JID, JID, IQ), IQr = Module:Function(JID, JID, IQ),
[A1] = IQr#iq.sub_el, [A1] = IQr#iq.sub_el,
@ -938,7 +938,7 @@ set_vcard_content(User, Server, Data, SomeContent) ->
Bin when is_binary(Bin) -> [SomeContent] Bin when is_binary(Bin) -> [SomeContent]
end, end,
[{_, Module, Function, _Opts}] = ets:lookup(sm_iqtable, {?NS_VCARD, Server}), [{_, Module, Function, _Opts}] = ets:lookup(sm_iqtable, {?NS_VCARD, Server}),
JID = jlib:make_jid(User, Server, get_module_resource(Server)), JID = jid:make(User, Server, get_module_resource(Server)),
IQ = #iq{type = get, xmlns = ?NS_VCARD}, IQ = #iq{type = get, xmlns = ?NS_VCARD},
IQr = Module:Function(JID, JID, IQ), IQr = Module:Function(JID, JID, IQ),
@ -1052,7 +1052,7 @@ get_roster(User, Server) ->
make_roster_xmlrpc(Roster) -> make_roster_xmlrpc(Roster) ->
lists:foldl( lists:foldl(
fun(Item, Res) -> fun(Item, Res) ->
JIDS = jlib:jid_to_string(Item#roster.jid), JIDS = jid:to_string(Item#roster.jid),
Nick = Item#roster.name, Nick = Item#roster.name,
Subs = atom_to_list(Item#roster.subscription), Subs = atom_to_list(Item#roster.subscription),
Ask = atom_to_list(Item#roster.ask), Ask = atom_to_list(Item#roster.ask),
@ -1118,7 +1118,7 @@ push_roster_item(LU, LS, U, S, Action) ->
end, ejabberd_sm:get_user_resources(LU, LS)). end, ejabberd_sm:get_user_resources(LU, LS)).
push_roster_item(LU, LS, R, U, S, Action) -> push_roster_item(LU, LS, R, U, S, Action) ->
LJID = jlib:make_jid(LU, LS, R), LJID = jid:make(LU, LS, R),
BroadcastEl = build_broadcast(U, S, Action), BroadcastEl = build_broadcast(U, S, Action),
ejabberd_sm:route(LJID, LJID, BroadcastEl), ejabberd_sm:route(LJID, LJID, BroadcastEl),
Item = build_roster_item(U, S, Action), Item = build_roster_item(U, S, Action),
@ -1127,14 +1127,14 @@ push_roster_item(LU, LS, R, U, S, Action) ->
build_roster_item(U, S, {add, Nick, Subs, Group}) -> build_roster_item(U, S, {add, Nick, Subs, Group}) ->
{xmlel, <<"item">>, {xmlel, <<"item">>,
[{<<"jid">>, jlib:jid_to_string(jlib:make_jid(U, S, <<>>))}, [{<<"jid">>, jid:to_string(jid:make(U, S, <<>>))},
{<<"name">>, Nick}, {<<"name">>, Nick},
{<<"subscription">>, Subs}], {<<"subscription">>, Subs}],
[{xmlel, <<"group">>, [], [{xmlcdata, Group}]}] [{xmlel, <<"group">>, [], [{xmlcdata, Group}]}]
}; };
build_roster_item(U, S, remove) -> build_roster_item(U, S, remove) ->
{xmlel, <<"item">>, {xmlel, <<"item">>,
[{<<"jid">>, jlib:jid_to_string(jlib:make_jid(U, S, <<>>))}, [{<<"jid">>, jid:to_string(jid:make(U, S, <<>>))},
{<<"subscription">>, <<"remove">>}], {<<"subscription">>, <<"remove">>}],
[] []
}. }.
@ -1193,8 +1193,8 @@ get_last(User, Server) ->
%% <aa xmlns='bb'>Cluth</aa> %% <aa xmlns='bb'>Cluth</aa>
private_get(Username, Host, Element, Ns) -> private_get(Username, Host, Element, Ns) ->
From = jlib:make_jid(Username, Host, <<>>), From = jid:make(Username, Host, <<>>),
To = jlib:make_jid(Username, Host, <<>>), To = jid:make(Username, Host, <<>>),
IQ = {iq, <<>>, get, ?NS_PRIVATE, <<>>, IQ = {iq, <<>>, get, ?NS_PRIVATE, <<>>,
{xmlel, <<"query">>, {xmlel, <<"query">>,
[{<<"xmlns">>,?NS_PRIVATE}], [{<<"xmlns">>,?NS_PRIVATE}],
@ -1216,8 +1216,8 @@ private_set(Username, Host, ElementString) ->
end. end.
private_set2(Username, Host, Xml) -> private_set2(Username, Host, Xml) ->
From = jlib:make_jid(Username, Host, <<>>), From = jid:make(Username, Host, <<>>),
To = jlib:make_jid(Username, Host, <<>>), To = jid:make(Username, Host, <<>>),
IQ = {iq, <<>>, set, ?NS_PRIVATE, <<>>, IQ = {iq, <<>>, set, ?NS_PRIVATE, <<>>,
{xmlel, <<"query">>, {xmlel, <<"query">>,
[{<<"xmlns">>, ?NS_PRIVATE}], [{<<"xmlns">>, ?NS_PRIVATE}],
@ -1261,7 +1261,7 @@ btl(B) -> binary_to_list(B).
srg_get_members(Group, Host) -> srg_get_members(Group, Host) ->
Members = mod_shared_roster:get_group_explicit_users(Host,Group), Members = mod_shared_roster:get_group_explicit_users(Host,Group),
[jlib:jid_to_string(jlib:make_jid(MUser, MServer, <<>>)) [jid:to_string(jid:make(MUser, MServer, <<>>))
|| {MUser, MServer} <- Members]. || {MUser, MServer} <- Members].
srg_user_add(User, Host, Group, GroupHost) -> srg_user_add(User, Host, Group, GroupHost) ->
@ -1292,8 +1292,8 @@ send_message(Type, From, To, Subject, Body) ->
%% If the user is local and is online in several resources, %% If the user is local and is online in several resources,
%% the packet is sent to all its resources. %% the packet is sent to all its resources.
send_packet_all_resources(FromJIDString, ToJIDString, Packet) -> send_packet_all_resources(FromJIDString, ToJIDString, Packet) ->
FromJID = jlib:string_to_jid(FromJIDString), FromJID = jid:from_string(FromJIDString),
ToJID = jlib:string_to_jid(ToJIDString), ToJID = jid:from_string(ToJIDString),
ToUser = ToJID#jid.user, ToUser = ToJID#jid.user,
ToServer = ToJID#jid.server, ToServer = ToJID#jid.server,
case ToJID#jid.resource of case ToJID#jid.resource of
@ -1317,7 +1317,7 @@ send_packet_all_resources(FromJID, ToUser, ToServer, Packet) ->
end. end.
send_packet_all_resources(FromJID, ToU, ToS, ToR, Packet) -> send_packet_all_resources(FromJID, ToU, ToS, ToR, Packet) ->
ToJID = jlib:make_jid(ToU, ToS, ToR), ToJID = jid:make(ToU, ToS, ToR),
ejabberd_router:route(FromJID, ToJID, Packet). ejabberd_router:route(FromJID, ToJID, Packet).
build_packet(Type, Subject, Body) -> build_packet(Type, Subject, Body) ->
@ -1335,8 +1335,8 @@ send_stanza_c2s(Username, Host, Resource, Stanza) ->
p1_fsm:send_event(C2sPid, {xmlstreamelement, XmlEl}). p1_fsm:send_event(C2sPid, {xmlstreamelement, XmlEl}).
privacy_set(Username, Host, QueryS) -> privacy_set(Username, Host, QueryS) ->
From = jlib:make_jid(Username, Host, <<"">>), From = jid:make(Username, Host, <<"">>),
To = jlib:make_jid(<<"">>, Host, <<"">>), To = jid:make(<<"">>, Host, <<"">>),
QueryEl = xml_stream:parse_element(QueryS), QueryEl = xml_stream:parse_element(QueryS),
StanzaEl = {xmlel, <<"iq">>, [{<<"type">>, <<"set">>}], [QueryEl]}, StanzaEl = {xmlel, <<"iq">>, [{<<"type">>, <<"set">>}], [QueryEl]},
IQ = jlib:iq_query_info(StanzaEl), IQ = jlib:iq_query_info(StanzaEl),
@ -1477,7 +1477,7 @@ decide_rip_jid({UName, UServer, _UResource}, Match_list) ->
decide_rip_jid({UName, UServer}, Match_list) -> decide_rip_jid({UName, UServer}, Match_list) ->
lists:any( lists:any(
fun(Match_string) -> fun(Match_string) ->
MJID = jlib:string_to_jid(list_to_binary(Match_string)), MJID = jid:from_string(list_to_binary(Match_string)),
MName = MJID#jid.luser, MName = MJID#jid.luser,
MServer = MJID#jid.lserver, MServer = MJID#jid.lserver,
Is_server = is_glob_match(UServer, MServer), Is_server = is_glob_match(UServer, MServer),

View File

@ -691,10 +691,10 @@ announce_all(From, To, Packet) ->
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN), Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
ejabberd_router:route(To, From, Err); ejabberd_router:route(To, From, Err);
allow -> allow ->
Local = jlib:make_jid(<<>>, To#jid.server, <<>>), Local = jid:make(<<>>, To#jid.server, <<>>),
lists:foreach( lists:foreach(
fun({User, Server}) -> fun({User, Server}) ->
Dest = jlib:make_jid(User, Server, <<>>), Dest = jid:make(User, Server, <<>>),
ejabberd_router:route(Local, Dest, Packet) ejabberd_router:route(Local, Dest, Packet)
end, ejabberd_auth:get_vh_registered_users(Host)) end, ejabberd_auth:get_vh_registered_users(Host))
end. end.
@ -706,10 +706,10 @@ announce_all_hosts_all(From, To, Packet) ->
Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN), Err = jlib:make_error_reply(Packet, ?ERR_FORBIDDEN),
ejabberd_router:route(To, From, Err); ejabberd_router:route(To, From, Err);
allow -> allow ->
Local = jlib:make_jid(<<>>, To#jid.server, <<>>), Local = jid:make(<<>>, To#jid.server, <<>>),
lists:foreach( lists:foreach(
fun({User, Server}) -> fun({User, Server}) ->
Dest = jlib:make_jid(User, Server, <<>>), Dest = jid:make(User, Server, <<>>),
ejabberd_router:route(Local, Dest, Packet) ejabberd_router:route(Local, Dest, Packet)
end, ejabberd_auth:dirty_get_registered_users()) end, ejabberd_auth:dirty_get_registered_users())
end. end.
@ -740,10 +740,10 @@ announce_all_hosts_online(From, To, Packet) ->
end. end.
announce_online1(Sessions, Server, Packet) -> announce_online1(Sessions, Server, Packet) ->
Local = jlib:make_jid(<<>>, Server, <<>>), Local = jid:make(<<>>, Server, <<>>),
lists:foreach( lists:foreach(
fun({U, S, R}) -> fun({U, S, R}) ->
Dest = jlib:make_jid(U, S, R), Dest = jid:make(U, S, R),
ejabberd_router:route(Local, Dest, Packet) ejabberd_router:route(Local, Dest, Packet)
end, Sessions). end, Sessions).
@ -770,7 +770,7 @@ announce_all_hosts_motd(From, To, Packet) ->
end. end.
announce_motd(Host, Packet) -> announce_motd(Host, Packet) ->
LServer = jlib:nameprep(Host), LServer = jid:nameprep(Host),
announce_motd_update(LServer, Packet), announce_motd_update(LServer, Packet),
Sessions = ejabberd_sm:get_vh_session_list(LServer), Sessions = ejabberd_sm:get_vh_session_list(LServer),
announce_online1(Sessions, LServer, Packet), announce_online1(Sessions, LServer, Packet),
@ -922,7 +922,7 @@ send_motd(#jid{luser = LUser, lserver = LServer} = JID, mnesia) ->
[#motd_users{}] -> [#motd_users{}] ->
ok; ok;
_ -> _ ->
Local = jlib:make_jid(<<>>, LServer, <<>>), Local = jid:make(<<>>, LServer, <<>>),
ejabberd_router:route(Local, JID, Packet), ejabberd_router:route(Local, JID, Packet),
F = fun() -> F = fun() ->
mnesia:write(#motd_users{us = US}) mnesia:write(#motd_users{us = US})
@ -940,7 +940,7 @@ send_motd(#jid{luser = LUser, lserver = LServer} = JID, riak) ->
{ok, #motd_users{}} -> {ok, #motd_users{}} ->
ok; ok;
_ -> _ ->
Local = jlib:make_jid(<<>>, LServer, <<>>), Local = jid:make(<<>>, LServer, <<>>),
ejabberd_router:route(Local, JID, Packet), ejabberd_router:route(Local, JID, Packet),
{atomic, ejabberd_riak:put( {atomic, ejabberd_riak:put(
#motd_users{us = US}, motd_users_schema(), #motd_users{us = US}, motd_users_schema(),
@ -963,7 +963,7 @@ send_motd(#jid{luser = LUser, lserver = LServer} = JID, odbc) when LUser /= <<>>
[<<"select username from motd " [<<"select username from motd "
"where username='">>, Username, <<"';">>]) of "where username='">>, Username, <<"';">>]) of
{selected, [<<"username">>], []} -> {selected, [<<"username">>], []} ->
Local = jlib:make_jid(<<"">>, LServer, <<"">>), Local = jid:make(<<"">>, LServer, <<"">>),
ejabberd_router:route(Local, JID, Packet), ejabberd_router:route(Local, JID, Packet),
F = fun() -> F = fun() ->
odbc_queries:update_t( odbc_queries:update_t(
@ -1038,10 +1038,10 @@ send_announcement_to_all(Host, SubjectS, BodyS) ->
children = SubjectEls ++ BodyEls children = SubjectEls ++ BodyEls
}, },
Sessions = ejabberd_sm:dirty_get_sessions_list(), Sessions = ejabberd_sm:dirty_get_sessions_list(),
Local = jlib:make_jid(<<>>, Host, <<>>), Local = jid:make(<<>>, Host, <<>>),
lists:foreach( lists:foreach(
fun({U, S, R}) -> fun({U, S, R}) ->
Dest = jlib:make_jid(U, S, R), Dest = jid:make(U, S, R),
ejabberd_router:route(Local, Dest, Packet) ejabberd_router:route(Local, Dest, Packet)
end, Sessions). end, Sessions).

View File

@ -118,7 +118,7 @@ parse_blocklist_items([#xmlel{name = <<"item">>,
JIDs) -> JIDs) ->
case xml:get_attr(<<"jid">>, Attrs) of case xml:get_attr(<<"jid">>, Attrs) of
{value, JID1} -> {value, JID1} ->
JID = jlib:jid_tolower(jlib:string_to_jid(JID1)), JID = jid:tolower(jid:from_string(JID1)),
parse_blocklist_items(Els, [JID | JIDs]); parse_blocklist_items(Els, [JID | JIDs]);
false -> parse_blocklist_items(Els, JIDs) false -> parse_blocklist_items(Els, JIDs)
end; end;
@ -375,13 +375,13 @@ make_userlist(Name, List) ->
#userlist{name = Name, list = List, needdb = NeedDb}. #userlist{name = Name, list = List, needdb = NeedDb}.
broadcast_list_update(LUser, LServer, Name, UserList) -> broadcast_list_update(LUser, LServer, Name, UserList) ->
ejabberd_sm:route(jlib:make_jid(LUser, LServer, ejabberd_sm:route(jid:make(LUser, LServer,
<<"">>), <<"">>),
jlib:make_jid(LUser, LServer, <<"">>), jid:make(LUser, LServer, <<"">>),
{broadcast, {privacy_list, UserList, Name}}). {broadcast, {privacy_list, UserList, Name}}).
broadcast_blocklist_event(LUser, LServer, Event) -> broadcast_blocklist_event(LUser, LServer, Event) ->
JID = jlib:make_jid(LUser, LServer, <<"">>), JID = jid:make(LUser, LServer, <<"">>),
ejabberd_sm:route(JID, JID, ejabberd_sm:route(JID, JID,
{broadcast, {blocking, Event}}). {broadcast, {blocking, Event}}).
@ -397,7 +397,7 @@ process_blocklist_get(LUser, LServer) ->
#xmlel{name = <<"item">>, #xmlel{name = <<"item">>,
attrs = attrs =
[{<<"jid">>, [{<<"jid">>,
jlib:jid_to_string(JID)}], jid:to_string(JID)}],
children = []} children = []}
end, end,
JIDs), JIDs),

View File

@ -235,7 +235,7 @@ c2s_presence_in(C2SState,
Delete = (Type == <<"unavailable">>) or Delete = (Type == <<"unavailable">>) or
(Type == <<"error">>), (Type == <<"error">>),
if Insert or Delete -> if Insert or Delete ->
LFrom = jlib:jid_tolower(From), LFrom = jid:tolower(From),
Rs = case ejabberd_c2s:get_aux_field(caps_resources, Rs = case ejabberd_c2s:get_aux_field(caps_resources,
C2SState) C2SState)
of of
@ -269,7 +269,7 @@ c2s_presence_in(C2SState,
c2s_filter_packet(InAcc, Host, C2SState, {pep_message, Feature}, To, _Packet) -> c2s_filter_packet(InAcc, Host, C2SState, {pep_message, Feature}, To, _Packet) ->
case ejabberd_c2s:get_aux_field(caps_resources, C2SState) of case ejabberd_c2s:get_aux_field(caps_resources, C2SState) of
{ok, Rs} -> {ok, Rs} ->
LTo = jlib:jid_tolower(To), LTo = jid:tolower(To),
case gb_trees:lookup(LTo, Rs) of case gb_trees:lookup(LTo, Rs) of
{value, Caps} -> {value, Caps} ->
Drop = not lists:member(Feature, get_features(Host, Caps)), Drop = not lists:member(Feature, get_features(Host, Caps)),
@ -417,7 +417,7 @@ feature_request(Host, From, Caps,
feature_response(IQReply, Host, From, Caps, feature_response(IQReply, Host, From, Caps,
SubNodes) SubNodes)
end, end,
ejabberd_local:route_iq(jlib:make_jid(<<"">>, Host, ejabberd_local:route_iq(jid:make(<<"">>, Host,
<<"">>), <<"">>),
From, IQ, F); From, IQ, F);
true -> feature_request(Host, From, Caps, Tail) true -> feature_request(Host, From, Caps, Tail)
@ -449,7 +449,7 @@ feature_response(_IQResult, Host, From, Caps,
feature_request(Host, From, Caps, SubNodes). feature_request(Host, From, Caps, SubNodes).
caps_read_fun(Host, Node) -> caps_read_fun(Host, Node) ->
LServer = jlib:nameprep(Host), LServer = jid:nameprep(Host),
DBType = gen_mod:db_type(LServer, ?MODULE), DBType = gen_mod:db_type(LServer, ?MODULE),
caps_read_fun(LServer, Node, DBType). caps_read_fun(LServer, Node, DBType).
@ -488,7 +488,7 @@ caps_read_fun(LServer, {Node, SubNode}, odbc) ->
end. end.
caps_write_fun(Host, Node, Features) -> caps_write_fun(Host, Node, Features) ->
LServer = jlib:nameprep(Host), LServer = jid:nameprep(Host),
DBType = gen_mod:db_type(LServer, ?MODULE), DBType = gen_mod:db_type(LServer, ?MODULE),
caps_write_fun(LServer, Node, Features, DBType). caps_write_fun(LServer, Node, Features, DBType).
@ -511,7 +511,7 @@ caps_write_fun(LServer, NodePair, Features, odbc) ->
end. end.
make_my_disco_hash(Host) -> make_my_disco_hash(Host) ->
JID = jlib:make_jid(<<"">>, Host, <<"">>), JID = jid:make(<<"">>, Host, <<"">>),
case {ejabberd_hooks:run_fold(disco_local_features, case {ejabberd_hooks:run_fold(disco_local_features,
Host, empty, [JID, JID, <<"">>, <<"">>]), Host, empty, [JID, JID, <<"">>, <<"">>]),
ejabberd_hooks:run_fold(disco_local_identity, Host, [], ejabberd_hooks:run_fold(disco_local_identity, Host, [],

View File

@ -104,7 +104,7 @@ iq_handler1(From, To, IQ) ->
iq_handler(From, _To, #iq{type=set, sub_el = #xmlel{name = Operation, children = []}} = IQ, CC)-> iq_handler(From, _To, #iq{type=set, sub_el = #xmlel{name = Operation, children = []}} = IQ, CC)->
?DEBUG("carbons IQ received: ~p", [IQ]), ?DEBUG("carbons IQ received: ~p", [IQ]),
{U, S, R} = jlib:jid_tolower(From), {U, S, R} = jid:tolower(From),
Result = case Operation of Result = case Operation of
<<"enable">>-> <<"enable">>->
?INFO_MSG("carbons enabled for user ~s@~s/~s", [U,S,R]), ?INFO_MSG("carbons enabled for user ~s@~s/~s", [U,S,R]),
@ -161,7 +161,7 @@ remove_connection(User, Server, Resource, _Status)->
%%% Internal %%% Internal
%% Direction = received | sent <received xmlns='urn:xmpp:carbons:1'/> %% Direction = received | sent <received xmlns='urn:xmpp:carbons:1'/>
send_copies(JID, To, Packet, Direction)-> send_copies(JID, To, Packet, Direction)->
{U, S, R} = jlib:jid_tolower(JID), {U, S, R} = jid:tolower(JID),
PrioRes = ejabberd_sm:get_user_present_resources(U, S), PrioRes = ejabberd_sm:get_user_present_resources(U, S),
{_, AvailRs} = lists:unzip(PrioRes), {_, AvailRs} = lists:unzip(PrioRes),
{MaxPrio, MaxRes} = case catch lists:max(PrioRes) of {MaxPrio, MaxRes} = case catch lists:max(PrioRes) of
@ -180,7 +180,7 @@ send_copies(JID, To, Packet, Direction)->
TargetJIDs = case {IsBareTo, R} of TargetJIDs = case {IsBareTo, R} of
{true, MaxRes} -> {true, MaxRes} ->
OrigTo = fun(Res) -> lists:member({MaxPrio, Res}, PrioRes) end, OrigTo = fun(Res) -> lists:member({MaxPrio, Res}, PrioRes) end,
[ {jlib:make_jid({U, S, CCRes}), CC_Version} [ {jid:make({U, S, CCRes}), CC_Version}
|| {CCRes, CC_Version} <- list(U, S), || {CCRes, CC_Version} <- list(U, S),
lists:member(CCRes, AvailRs), not OrigTo(CCRes) ]; lists:member(CCRes, AvailRs), not OrigTo(CCRes) ];
{true, _} -> {true, _} ->
@ -191,16 +191,16 @@ send_copies(JID, To, Packet, Direction)->
%% MaxRes) in order to avoid duplicates. %% MaxRes) in order to avoid duplicates.
[]; [];
{false, _} -> {false, _} ->
[ {jlib:make_jid({U, S, CCRes}), CC_Version} [ {jid:make({U, S, CCRes}), CC_Version}
|| {CCRes, CC_Version} <- list(U, S), || {CCRes, CC_Version} <- list(U, S),
lists:member(CCRes, AvailRs), CCRes /= R ] lists:member(CCRes, AvailRs), CCRes /= R ]
%TargetJIDs = lists:delete(JID, [ jlib:make_jid({U, S, CCRes}) || CCRes <- list(U, S) ]), %TargetJIDs = lists:delete(JID, [ jid:make({U, S, CCRes}) || CCRes <- list(U, S) ]),
end, end,
lists:map(fun({Dest,Version}) -> lists:map(fun({Dest,Version}) ->
{_, _, Resource} = jlib:jid_tolower(Dest), {_, _, Resource} = jid:tolower(Dest),
?DEBUG("Sending: ~p =/= ~p", [R, Resource]), ?DEBUG("Sending: ~p =/= ~p", [R, Resource]),
Sender = jlib:make_jid({U, S, <<>>}), Sender = jid:make({U, S, <<>>}),
%{xmlelement, N, A, C} = Packet, %{xmlelement, N, A, C} = Packet,
New = build_forward_packet(JID, Packet, Sender, Dest, Direction, Version), New = build_forward_packet(JID, Packet, Sender, Dest, Direction, Version),
ejabberd_router:route(Sender, Dest, New) ejabberd_router:route(Sender, Dest, New)
@ -211,8 +211,8 @@ build_forward_packet(JID, Packet, Sender, Dest, Direction, ?NS_CARBONS_2) ->
#xmlel{name = <<"message">>, #xmlel{name = <<"message">>,
attrs = [{<<"xmlns">>, <<"jabber:client">>}, attrs = [{<<"xmlns">>, <<"jabber:client">>},
{<<"type">>, message_type(Packet)}, {<<"type">>, message_type(Packet)},
{<<"from">>, jlib:jid_to_string(Sender)}, {<<"from">>, jid:to_string(Sender)},
{<<"to">>, jlib:jid_to_string(Dest)}], {<<"to">>, jid:to_string(Dest)}],
children = [ children = [
#xmlel{name = list_to_binary(atom_to_list(Direction)), #xmlel{name = list_to_binary(atom_to_list(Direction)),
attrs = [{<<"xmlns">>, ?NS_CARBONS_2}], attrs = [{<<"xmlns">>, ?NS_CARBONS_2}],
@ -227,8 +227,8 @@ build_forward_packet(JID, Packet, Sender, Dest, Direction, ?NS_CARBONS_1) ->
#xmlel{name = <<"message">>, #xmlel{name = <<"message">>,
attrs = [{<<"xmlns">>, <<"jabber:client">>}, attrs = [{<<"xmlns">>, <<"jabber:client">>},
{<<"type">>, message_type(Packet)}, {<<"type">>, message_type(Packet)},
{<<"from">>, jlib:jid_to_string(Sender)}, {<<"from">>, jid:to_string(Sender)},
{<<"to">>, jlib:jid_to_string(Dest)}], {<<"to">>, jid:to_string(Dest)}],
children = [ children = [
#xmlel{name = list_to_binary(atom_to_list(Direction)), #xmlel{name = list_to_binary(atom_to_list(Direction)),
attrs = [{<<"xmlns">>, ?NS_CARBONS_1}]}, attrs = [{<<"xmlns">>, ?NS_CARBONS_1}]},
@ -259,7 +259,7 @@ complete_packet(From, #xmlel{name = <<"message">>, attrs = OrigAttrs} = Packet,
Attrs = lists:keystore(<<"xmlns">>, 1, OrigAttrs, {<<"xmlns">>, <<"jabber:client">>}), Attrs = lists:keystore(<<"xmlns">>, 1, OrigAttrs, {<<"xmlns">>, <<"jabber:client">>}),
case proplists:get_value(<<"from">>, Attrs) of case proplists:get_value(<<"from">>, Attrs) of
undefined -> undefined ->
Packet#xmlel{attrs = [{<<"from">>, jlib:jid_to_string(From)}|Attrs]}; Packet#xmlel{attrs = [{<<"from">>, jid:to_string(From)}|Attrs]};
_ -> _ ->
Packet#xmlel{attrs = Attrs} Packet#xmlel{attrs = Attrs}
end; end;

View File

@ -114,7 +114,7 @@ stop(Host) ->
-define(NODEJID(To, Name, Node), -define(NODEJID(To, Name, Node),
#xmlel{name = <<"item">>, #xmlel{name = <<"item">>,
attrs = attrs =
[{<<"jid">>, jlib:jid_to_string(To)}, [{<<"jid">>, jid:to_string(To)},
{<<"name">>, ?T(Lang, Name)}, {<<"node">>, Node}], {<<"name">>, ?T(Lang, Name)}, {<<"node">>, Node}],
children = []}). children = []}).
@ -292,7 +292,7 @@ adhoc_sm_items(Acc, From, #jid{lserver = LServer} = To,
end, end,
Nodes = [#xmlel{name = <<"item">>, Nodes = [#xmlel{name = <<"item">>,
attrs = attrs =
[{<<"jid">>, jlib:jid_to_string(To)}, [{<<"jid">>, jid:to_string(To)},
{<<"name">>, ?T(Lang, <<"Configuration">>)}, {<<"name">>, ?T(Lang, <<"Configuration">>)},
{<<"node">>, <<"config">>}], {<<"node">>, <<"config">>}],
children = []}], children = []}],
@ -415,7 +415,7 @@ get_permission_level(JID) ->
allow -> allow ->
PermLev = get_permission_level(From), PermLev = get_permission_level(From),
case get_local_items({PermLev, LServer}, LNode, case get_local_items({PermLev, LServer}, LNode,
jlib:jid_to_string(To), Lang) jid:to_string(To), Lang)
of of
{result, Res} -> {result, Res}; {result, Res} -> {result, Res};
{error, Error} -> {error, Error} {error, Error} -> {error, Error}
@ -437,7 +437,7 @@ get_local_items(Acc, From, #jid{lserver = LServer} = To,
allow -> allow ->
PermLev = get_permission_level(From), PermLev = get_permission_level(From),
case get_local_items({PermLev, LServer}, [], case get_local_items({PermLev, LServer}, [],
jlib:jid_to_string(To), Lang) jid:to_string(To), Lang)
of of
{result, Res} -> {result, Items ++ Res}; {result, Res} -> {result, Items ++ Res};
{error, _Error} -> {result, Items} {error, _Error} -> {result, Items}
@ -1817,7 +1817,7 @@ set_form(From, Host, ?NS_ADMINL(<<"add-user">>), _Lang,
AccountString = get_value(<<"accountjid">>, XData), AccountString = get_value(<<"accountjid">>, XData),
Password = get_value(<<"password">>, XData), Password = get_value(<<"password">>, XData),
Password = get_value(<<"password-verify">>, XData), Password = get_value(<<"password-verify">>, XData),
AccountJID = jlib:string_to_jid(AccountString), AccountJID = jid:from_string(AccountString),
User = AccountJID#jid.luser, User = AccountJID#jid.luser,
Server = AccountJID#jid.lserver, Server = AccountJID#jid.lserver,
true = lists:member(Server, ?MYHOSTS), true = lists:member(Server, ?MYHOSTS),
@ -1831,7 +1831,7 @@ set_form(From, Host, ?NS_ADMINL(<<"delete-user">>),
XData), XData),
[_ | _] = AccountStringList, [_ | _] = AccountStringList,
ASL2 = lists:map(fun (AccountString) -> ASL2 = lists:map(fun (AccountString) ->
JID = jlib:string_to_jid(AccountString), JID = jid:from_string(AccountString),
User = JID#jid.luser, User = JID#jid.luser,
Server = JID#jid.lserver, Server = JID#jid.lserver,
true = Server == Host orelse true = Server == Host orelse
@ -1846,7 +1846,7 @@ set_form(From, Host, ?NS_ADMINL(<<"delete-user">>),
set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>), set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
Lang, XData) -> Lang, XData) ->
AccountString = get_value(<<"accountjid">>, XData), AccountString = get_value(<<"accountjid">>, XData),
JID = jlib:string_to_jid(AccountString), JID = jid:from_string(AccountString),
LUser = JID#jid.luser, LUser = JID#jid.luser,
LServer = JID#jid.lserver, LServer = JID#jid.lserver,
true = LServer == Host orelse true = LServer == Host orelse
@ -1872,7 +1872,7 @@ set_form(From, Host, ?NS_ADMINL(<<"end-user-session">>),
set_form(From, Host, set_form(From, Host,
?NS_ADMINL(<<"get-user-password">>), Lang, XData) -> ?NS_ADMINL(<<"get-user-password">>), Lang, XData) ->
AccountString = get_value(<<"accountjid">>, XData), AccountString = get_value(<<"accountjid">>, XData),
JID = jlib:string_to_jid(AccountString), JID = jid:from_string(AccountString),
User = JID#jid.luser, User = JID#jid.luser,
Server = JID#jid.lserver, Server = JID#jid.lserver,
true = Server == Host orelse true = Server == Host orelse
@ -1892,7 +1892,7 @@ set_form(From, Host,
?NS_ADMINL(<<"change-user-password">>), _Lang, XData) -> ?NS_ADMINL(<<"change-user-password">>), _Lang, XData) ->
AccountString = get_value(<<"accountjid">>, XData), AccountString = get_value(<<"accountjid">>, XData),
Password = get_value(<<"password">>, XData), Password = get_value(<<"password">>, XData),
JID = jlib:string_to_jid(AccountString), JID = jid:from_string(AccountString),
User = JID#jid.luser, User = JID#jid.luser,
Server = JID#jid.lserver, Server = JID#jid.lserver,
true = Server == Host orelse true = Server == Host orelse
@ -1903,7 +1903,7 @@ set_form(From, Host,
set_form(From, Host, set_form(From, Host,
?NS_ADMINL(<<"get-user-lastlogin">>), Lang, XData) -> ?NS_ADMINL(<<"get-user-lastlogin">>), Lang, XData) ->
AccountString = get_value(<<"accountjid">>, XData), AccountString = get_value(<<"accountjid">>, XData),
JID = jlib:string_to_jid(AccountString), JID = jid:from_string(AccountString),
User = JID#jid.luser, User = JID#jid.luser,
Server = JID#jid.lserver, Server = JID#jid.lserver,
true = Server == Host orelse true = Server == Host orelse
@ -1938,7 +1938,7 @@ set_form(From, Host,
set_form(From, Host, ?NS_ADMINL(<<"user-stats">>), Lang, set_form(From, Host, ?NS_ADMINL(<<"user-stats">>), Lang,
XData) -> XData) ->
AccountString = get_value(<<"accountjid">>, XData), AccountString = get_value(<<"accountjid">>, XData),
JID = jlib:string_to_jid(AccountString), JID = jid:from_string(AccountString),
User = JID#jid.luser, User = JID#jid.luser,
Server = JID#jid.lserver, Server = JID#jid.lserver,
true = Server == Host orelse true = Server == Host orelse
@ -2031,7 +2031,7 @@ stop_node(From, Host, ENode, Action, XData) ->
?NS_XDATA}, ?NS_XDATA},
{<<"type">>, <<"submit">>}], {<<"type">>, <<"submit">>}],
children = SubEls}]}, children = SubEls}]},
To = jlib:make_jid(<<"">>, Host, <<"">>), To = jid:make(<<"">>, Host, <<"">>),
mod_announce:announce_commands(empty, From, To, Request) mod_announce:announce_commands(empty, From, To, Request)
end, end,
Time = timer:seconds(Delay), Time = timer:seconds(Delay),

View File

@ -167,7 +167,7 @@ code_change(_OldVsn, State, _Extra) -> {ok, State}.
%% Finally, the received response is printed in the ejabberd log file. %% Finally, the received response is printed in the ejabberd log file.
do_client_version(disabled, _From, _To) -> ok; do_client_version(disabled, _From, _To) -> ok;
do_client_version(enabled, From, To) -> do_client_version(enabled, From, To) ->
ToS = jlib:jid_to_string(To), ToS = jid:to_string(To),
Random_resource = Random_resource =
iolist_to_binary(integer_to_list(random:uniform(100000))), iolist_to_binary(integer_to_list(random:uniform(100000))),
From2 = From#jid{resource = Random_resource, From2 = From#jid{resource = Random_resource,

View File

@ -114,7 +114,7 @@ check_permissions(#request{auth = HTTPAuth, headers = Headers}, Command)
Auth = Auth =
case HTTPAuth of case HTTPAuth of
{SJID, Pass} -> {SJID, Pass} ->
case jlib:string_to_jid(SJID) of case jid:from_string(SJID) of
#jid{user = User, server = Server} -> #jid{user = User, server = Server} ->
case ejabberd_auth:check_password(User, Server, Pass) of case ejabberd_auth:check_password(User, Server, Pass) of
true -> {ok, {User, Server, Pass, Admin}}; true -> {ok, {User, Server, Pass, Admin}};

View File

@ -560,12 +560,12 @@ process_iq(From,
end; end;
{error, Error} -> {error, Error} ->
?DEBUG("Cannot parse request from ~s", ?DEBUG("Cannot parse request from ~s",
[jlib:jid_to_string(From)]), [jid:to_string(From)]),
IQ#iq{type = error, sub_el = [SubEl, Error]} IQ#iq{type = error, sub_el = [SubEl, Error]}
end; end;
deny -> deny ->
?DEBUG("Denying HTTP upload slot request from ~s", ?DEBUG("Denying HTTP upload slot request from ~s",
[jlib:jid_to_string(From)]), [jid:to_string(From)]),
IQ#iq{type = error, sub_el = [SubEl, ?ERR_FORBIDDEN]} IQ#iq{type = error, sub_el = [SubEl, ?ERR_FORBIDDEN]}
end; end;
process_iq(_From, #iq{sub_el = SubEl} = IQ, _State) -> process_iq(_From, #iq{sub_el = SubEl} = IQ, _State) ->
@ -611,7 +611,7 @@ create_slot(#state{service_url = undefined, max_size = MaxSize},
Text = <<"File larger than ", (jlib:integer_to_binary(MaxSize))/binary, Text = <<"File larger than ", (jlib:integer_to_binary(MaxSize))/binary,
" Bytes.">>, " Bytes.">>,
?INFO_MSG("Rejecting file ~s from ~s (too large: ~B bytes)", ?INFO_MSG("Rejecting file ~s from ~s (too large: ~B bytes)",
[File, jlib:jid_to_string(JID), Size]), [File, jid:to_string(JID), Size]),
{error, ?ERRT_NOT_ACCEPTABLE(Lang, Text)}; {error, ?ERRT_NOT_ACCEPTABLE(Lang, Text)};
create_slot(#state{service_url = undefined, create_slot(#state{service_url = undefined,
jid_in_url = JIDinURL, jid_in_url = JIDinURL,
@ -627,7 +627,7 @@ create_slot(#state{service_url = undefined,
RandStr = make_rand_string(SecretLength), RandStr = make_rand_string(SecretLength),
FileStr = make_file_string(File), FileStr = make_file_string(File),
?INFO_MSG("Got HTTP upload slot for ~s (file: ~s)", ?INFO_MSG("Got HTTP upload slot for ~s (file: ~s)",
[jlib:jid_to_string(JID), File]), [jid:to_string(JID), File]),
{ok, [UserStr, RandStr, FileStr]}; {ok, [UserStr, RandStr, FileStr]};
deny -> deny ->
{error, ?ERR_SERVICE_UNAVAILABLE}; {error, ?ERR_SERVICE_UNAVAILABLE};
@ -641,7 +641,7 @@ create_slot(#state{service_url = ServiceURL},
HttpOptions = [{timeout, ?SERVICE_REQUEST_TIMEOUT}], HttpOptions = [{timeout, ?SERVICE_REQUEST_TIMEOUT}],
SizeStr = jlib:integer_to_binary(Size), SizeStr = jlib:integer_to_binary(Size),
GetRequest = binary_to_list(ServiceURL) ++ GetRequest = binary_to_list(ServiceURL) ++
"?jid=" ++ ?URL_ENC(jlib:jid_to_string({U, S, <<"">>})) ++ "?jid=" ++ ?URL_ENC(jid:to_string({U, S, <<"">>})) ++
"&name=" ++ ?URL_ENC(File) ++ "&name=" ++ ?URL_ENC(File) ++
"&size=" ++ ?URL_ENC(SizeStr) ++ "&size=" ++ ?URL_ENC(SizeStr) ++
"&content_type=" ++ ?URL_ENC(ContentType), "&content_type=" ++ ?URL_ENC(ContentType),
@ -651,32 +651,32 @@ create_slot(#state{service_url = ServiceURL},
[<<"http", _/binary>> = PutURL, [<<"http", _/binary>> = PutURL,
<<"http", _/binary>> = GetURL] -> <<"http", _/binary>> = GetURL] ->
?INFO_MSG("Got HTTP upload slot for ~s (file: ~s)", ?INFO_MSG("Got HTTP upload slot for ~s (file: ~s)",
[jlib:jid_to_string(JID), File]), [jid:to_string(JID), File]),
{ok, PutURL, GetURL}; {ok, PutURL, GetURL};
Lines -> Lines ->
?ERROR_MSG("Can't parse data received for ~s from <~s>: ~p", ?ERROR_MSG("Can't parse data received for ~s from <~s>: ~p",
[jlib:jid_to_string(JID), ServiceURL, Lines]), [jid:to_string(JID), ServiceURL, Lines]),
{error, ?ERR_SERVICE_UNAVAILABLE} {error, ?ERR_SERVICE_UNAVAILABLE}
end; end;
{ok, {402, _Body}} -> {ok, {402, _Body}} ->
?INFO_MSG("Got status code 402 for ~s from <~s>", ?INFO_MSG("Got status code 402 for ~s from <~s>",
[jlib:jid_to_string(JID), ServiceURL]), [jid:to_string(JID), ServiceURL]),
{error, ?ERR_RESOURCE_CONSTRAINT}; {error, ?ERR_RESOURCE_CONSTRAINT};
{ok, {403, _Body}} -> {ok, {403, _Body}} ->
?INFO_MSG("Got status code 403 for ~s from <~s>", ?INFO_MSG("Got status code 403 for ~s from <~s>",
[jlib:jid_to_string(JID), ServiceURL]), [jid:to_string(JID), ServiceURL]),
{error, ?ERR_NOT_ALLOWED}; {error, ?ERR_NOT_ALLOWED};
{ok, {413, _Body}} -> {ok, {413, _Body}} ->
?INFO_MSG("Got status code 413 for ~s from <~s>", ?INFO_MSG("Got status code 413 for ~s from <~s>",
[jlib:jid_to_string(JID), ServiceURL]), [jid:to_string(JID), ServiceURL]),
{error, ?ERR_NOT_ACCEPTABLE}; {error, ?ERR_NOT_ACCEPTABLE};
{ok, {Code, _Body}} -> {ok, {Code, _Body}} ->
?ERROR_MSG("Got unexpected status code for ~s from <~s>: ~B", ?ERROR_MSG("Got unexpected status code for ~s from <~s>: ~B",
[jlib:jid_to_string(JID), ServiceURL, Code]), [jid:to_string(JID), ServiceURL, Code]),
{error, ?ERR_SERVICE_UNAVAILABLE}; {error, ?ERR_SERVICE_UNAVAILABLE};
{error, Reason} -> {error, Reason} ->
?ERROR_MSG("Error requesting upload slot for ~s from <~s>: ~p", ?ERROR_MSG("Error requesting upload slot for ~s from <~s>: ~p",
[jlib:jid_to_string(JID), ServiceURL, Reason]), [jid:to_string(JID), ServiceURL, Reason]),
{error, ?ERR_SERVICE_UNAVAILABLE} {error, ?ERR_SERVICE_UNAVAILABLE}
end. end.
@ -959,7 +959,7 @@ thumb_el(Path, URI) ->
-spec remove_user(binary(), binary()) -> ok. -spec remove_user(binary(), binary()) -> ok.
remove_user(User, Server) -> remove_user(User, Server) ->
ServerHost = jlib:nameprep(Server), ServerHost = jid:nameprep(Server),
DocRoot = gen_mod:get_module_opt(ServerHost, ?MODULE, docroot, DocRoot = gen_mod:get_module_opt(ServerHost, ?MODULE, docroot,
fun iolist_to_binary/1, fun iolist_to_binary/1,
<<"@HOME@/upload">>), <<"@HOME@/upload">>),
@ -968,7 +968,7 @@ remove_user(User, Server) ->
(node) -> node (node) -> node
end, end,
sha1), sha1),
UserStr = make_user_string(jlib:make_jid(User, Server, <<"">>), JIDinURL), UserStr = make_user_string(jid:make(User, Server, <<"">>), JIDinURL),
UserDir = str:join([expand_home(DocRoot), UserStr], <<$/>>), UserDir = str:join([expand_home(DocRoot), UserStr], <<$/>>),
case del_tree(UserDir) of case del_tree(UserDir) of
ok -> ok ->

View File

@ -181,24 +181,24 @@ handle_cast({handle_slot_request, #jid{user = U, server = S} = JID, Path, Size},
NewSize = case {HardQuota, SoftQuota} of NewSize = case {HardQuota, SoftQuota} of
{0, 0} -> {0, 0} ->
?DEBUG("No quota specified for ~s", ?DEBUG("No quota specified for ~s",
[jlib:jid_to_string(JID)]), [jid:to_string(JID)]),
undefined; undefined;
{0, _} -> {0, _} ->
?WARNING_MSG("No hard quota specified for ~s", ?WARNING_MSG("No hard quota specified for ~s",
[jlib:jid_to_string(JID)]), [jid:to_string(JID)]),
enforce_quota(Path, Size, OldSize, SoftQuota, SoftQuota); enforce_quota(Path, Size, OldSize, SoftQuota, SoftQuota);
{_, 0} -> {_, 0} ->
?WARNING_MSG("No soft quota specified for ~s", ?WARNING_MSG("No soft quota specified for ~s",
[jlib:jid_to_string(JID)]), [jid:to_string(JID)]),
enforce_quota(Path, Size, OldSize, HardQuota, HardQuota); enforce_quota(Path, Size, OldSize, HardQuota, HardQuota);
_ when SoftQuota > HardQuota -> _ when SoftQuota > HardQuota ->
?WARNING_MSG("Bad quota for ~s (soft: ~p, hard: ~p)", ?WARNING_MSG("Bad quota for ~s (soft: ~p, hard: ~p)",
[jlib:jid_to_string(JID), [jid:to_string(JID),
SoftQuota, HardQuota]), SoftQuota, HardQuota]),
enforce_quota(Path, Size, OldSize, SoftQuota, SoftQuota); enforce_quota(Path, Size, OldSize, SoftQuota, SoftQuota);
_ -> _ ->
?DEBUG("Enforcing quota for ~s", ?DEBUG("Enforcing quota for ~s",
[jlib:jid_to_string(JID)]), [jid:to_string(JID)]),
enforce_quota(Path, Size, OldSize, SoftQuota, HardQuota) enforce_quota(Path, Size, OldSize, SoftQuota, HardQuota)
end, end,
NewDiskUsage = if is_integer(NewSize) -> NewDiskUsage = if is_integer(NewSize) ->

View File

@ -578,7 +578,7 @@ process_irc_register(ServerHost, Host, From, _To,
end. end.
get_data(ServerHost, Host, From) -> get_data(ServerHost, Host, From) ->
LServer = jlib:nameprep(ServerHost), LServer = jid:nameprep(ServerHost),
get_data(LServer, Host, From, get_data(LServer, Host, From,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -604,7 +604,7 @@ get_data(LServer, Host, From, riak) ->
end; end;
get_data(LServer, Host, From, odbc) -> get_data(LServer, Host, From, odbc) ->
SJID = SJID =
ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(jlib:jid_remove_resource(From)))), ejabberd_odbc:escape(jid:to_string(jid:tolower(jid:remove_resource(From)))),
SHost = ejabberd_odbc:escape(Host), SHost = ejabberd_odbc:escape(Host),
case catch ejabberd_odbc:sql_query(LServer, case catch ejabberd_odbc:sql_query(LServer,
[<<"select data from irc_custom where jid='">>, [<<"select data from irc_custom where jid='">>,
@ -722,12 +722,12 @@ get_form(_ServerHost, _Host, _, _, _Lang) ->
{error, ?ERR_SERVICE_UNAVAILABLE}. {error, ?ERR_SERVICE_UNAVAILABLE}.
set_data(ServerHost, Host, From, Data) -> set_data(ServerHost, Host, From, Data) ->
LServer = jlib:nameprep(ServerHost), LServer = jid:nameprep(ServerHost),
set_data(LServer, Host, From, data_to_binary(From, Data), set_data(LServer, Host, From, data_to_binary(From, Data),
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
set_data(_LServer, Host, From, Data, mnesia) -> set_data(_LServer, Host, From, Data, mnesia) ->
{LUser, LServer, _} = jlib:jid_tolower(From), {LUser, LServer, _} = jid:tolower(From),
US = {LUser, LServer}, US = {LUser, LServer},
F = fun () -> F = fun () ->
mnesia:write(#irc_custom{us_host = {US, Host}, mnesia:write(#irc_custom{us_host = {US, Host},
@ -735,14 +735,14 @@ set_data(_LServer, Host, From, Data, mnesia) ->
end, end,
mnesia:transaction(F); mnesia:transaction(F);
set_data(LServer, Host, From, Data, riak) -> set_data(LServer, Host, From, Data, riak) ->
{LUser, LServer, _} = jlib:jid_tolower(From), {LUser, LServer, _} = jid:tolower(From),
US = {LUser, LServer}, US = {LUser, LServer},
{atomic, ejabberd_riak:put(#irc_custom{us_host = {US, Host}, {atomic, ejabberd_riak:put(#irc_custom{us_host = {US, Host},
data = Data}, data = Data},
irc_custom_schema())}; irc_custom_schema())};
set_data(LServer, Host, From, Data, odbc) -> set_data(LServer, Host, From, Data, odbc) ->
SJID = SJID =
ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(jlib:jid_remove_resource(From)))), ejabberd_odbc:escape(jid:to_string(jid:tolower(jid:remove_resource(From)))),
SHost = ejabberd_odbc:escape(Host), SHost = ejabberd_odbc:escape(Host),
SData = ejabberd_odbc:encode_term(Data), SData = ejabberd_odbc:encode_term(Data),
F = fun () -> F = fun () ->
@ -921,7 +921,7 @@ adhoc_join(From, To,
<<"invite">>, <<"invite">>,
attrs = attrs =
[{<<"from">>, [{<<"from">>,
jlib:jid_to_string(From)}], jid:to_string(From)}],
children = children =
[#xmlel{name [#xmlel{name
= =
@ -952,7 +952,7 @@ adhoc_join(From, To,
Lang, Lang,
<<"Join the IRC channel in this Jabber ID: ~s">>), <<"Join the IRC channel in this Jabber ID: ~s">>),
[RoomJID]))}]}]}, [RoomJID]))}]}]},
ejabberd_router:route(jlib:string_to_jid(RoomJID), From, ejabberd_router:route(jid:from_string(RoomJID), From,
Invite), Invite),
adhoc:produce_response(Request, adhoc:produce_response(Request,
#adhoc_response{status = #adhoc_response{status =
@ -1248,7 +1248,7 @@ data_to_binary(JID, Data) ->
?ERROR_MSG("failed to convert " ?ERROR_MSG("failed to convert "
"parameter ~p for user ~s", "parameter ~p for user ~s",
[Param, [Param,
jlib:jid_to_string(JID)]); jid:to_string(JID)]);
true -> true ->
?ERROR_MSG("failed to convert " ?ERROR_MSG("failed to convert "
"parameter ~p", "parameter ~p",
@ -1295,7 +1295,7 @@ update_table() ->
fun(#irc_custom{us_host = {_, H}}) -> H end, fun(#irc_custom{us_host = {_, H}}) -> H end,
fun(#irc_custom{us_host = {{U, S}, H}, fun(#irc_custom{us_host = {{U, S}, H},
data = Data} = R) -> data = Data} = R) ->
JID = jlib:make_jid(U, S, <<"">>), JID = jid:make(U, S, <<"">>),
R#irc_custom{us_host = {{iolist_to_binary(U), R#irc_custom{us_host = {{iolist_to_binary(U),
iolist_to_binary(S)}, iolist_to_binary(S)},
iolist_to_binary(H)}, iolist_to_binary(H)},
@ -1313,8 +1313,8 @@ export(_Server) ->
case str:suffix(Host, IRCHost) of case str:suffix(Host, IRCHost) of
true -> true ->
SJID = ejabberd_odbc:escape( SJID = ejabberd_odbc:escape(
jlib:jid_to_string( jid:to_string(
jlib:make_jid(U, S, <<"">>))), jid:make(U, S, <<"">>))),
SIRCHost = ejabberd_odbc:escape(IRCHost), SIRCHost = ejabberd_odbc:escape(IRCHost),
SData = ejabberd_odbc:encode_term(Data), SData = ejabberd_odbc:encode_term(Data),
[[<<"delete from irc_custom where jid='">>, SJID, [[<<"delete from irc_custom where jid='">>, SJID,
@ -1331,7 +1331,7 @@ export(_Server) ->
import(_LServer) -> import(_LServer) ->
[{<<"select jid, host, data from irc_custom;">>, [{<<"select jid, host, data from irc_custom;">>,
fun([SJID, IRCHost, SData]) -> fun([SJID, IRCHost, SData]) ->
#jid{luser = U, lserver = S} = jlib:string_to_jid(SJID), #jid{luser = U, lserver = S} = jid:from_string(SJID),
Data = ejabberd_odbc:decode_term(SData), Data = ejabberd_odbc:decode_term(SData),
#irc_custom{us_host = {{U, S}, IRCHost}, #irc_custom{us_host = {{U, S}, IRCHost},
data = Data} data = Data}

View File

@ -306,7 +306,7 @@ handle_info({route_chan, Channel, Resource,
of of
<<"">> -> <<"">> ->
ejabberd_router:route( ejabberd_router:route(
jlib:make_jid( jid:make(
iolist_to_binary([Channel, iolist_to_binary([Channel,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
@ -430,7 +430,7 @@ handle_info({route_chan, Channel, Resource,
#xmlel{name = <<"iq">>} = El}, #xmlel{name = <<"iq">>} = El},
StateName, StateData) -> StateName, StateData) ->
From = StateData#state.user, From = StateData#state.user,
To = jlib:make_jid(iolist_to_binary([Channel, <<"%">>, To = jid:make(iolist_to_binary([Channel, <<"%">>,
StateData#state.server]), StateData#state.server]),
StateData#state.host, StateData#state.nick), StateData#state.host, StateData#state.nick),
_ = case jlib:iq_query_info(El) of _ = case jlib:iq_query_info(El) of
@ -716,7 +716,7 @@ terminate(_Reason, _StateName, FullStateData) ->
send_stanza(Chan, StateData, Stanza) -> send_stanza(Chan, StateData, Stanza) ->
ejabberd_router:route( ejabberd_router:route(
jlib:make_jid( jid:make(
iolist_to_binary([Chan, iolist_to_binary([Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
@ -770,9 +770,9 @@ bounce_messages(Reason) ->
<<"error">> -> ok; <<"error">> -> ok;
_ -> _ ->
Err = jlib:make_error_reply(El, <<"502">>, Reason), Err = jlib:make_error_reply(El, <<"502">>, Reason),
From = jlib:string_to_jid(xml:get_attr_s(<<"from">>, From = jid:from_string(xml:get_attr_s(<<"from">>,
Attrs)), Attrs)),
To = jlib:string_to_jid(xml:get_attr_s(<<"to">>, To = jid:from_string(xml:get_attr_s(<<"to">>,
Attrs)), Attrs)),
ejabberd_router:route(To, From, Err) ejabberd_router:route(To, From, Err)
end, end,
@ -830,7 +830,7 @@ process_channel_list_user(StateData, Chan, User) ->
{U2, <<"admin">>, <<"moderator">>}; {U2, <<"admin">>, <<"moderator">>};
_ -> {User1, <<"member">>, <<"participant">>} _ -> {User1, <<"member">>, <<"participant">>}
end, end,
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Chan, ejabberd_router:route(jid:make(iolist_to_binary([Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
StateData#state.host, User2), StateData#state.host, User2),
@ -860,7 +860,7 @@ process_channel_topic(StateData, Chan, String) ->
Msg = ejabberd_regexp:replace(String, <<".*332[^:]*:">>, Msg = ejabberd_regexp:replace(String, <<".*332[^:]*:">>,
<<"">>), <<"">>),
Msg1 = filter_message(Msg), Msg1 = filter_message(Msg),
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Chan, ejabberd_router:route(jid:make(iolist_to_binary([Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
StateData#state.host, <<"">>), StateData#state.host, <<"">>),
@ -889,7 +889,7 @@ process_channel_topic_who(StateData, Chan, String) ->
_ -> String _ -> String
end, end,
Msg2 = filter_message(Msg1), Msg2 = filter_message(Msg1),
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Chan, ejabberd_router:route(jid:make(iolist_to_binary([Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
StateData#state.host, <<"">>), StateData#state.host, <<"">>),
@ -921,7 +921,7 @@ process_nick_in_use(StateData, String) ->
% Shouldn't happen with a well behaved server % Shouldn't happen with a well behaved server
StateData; StateData;
Chan -> Chan ->
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Chan, ejabberd_router:route(jid:make(iolist_to_binary([Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
StateData#state.host, StateData#state.host,
@ -938,7 +938,7 @@ process_num_error(StateData, String) ->
<<"continue">>), <<"continue">>),
lists:foreach(fun (Chan) -> lists:foreach(fun (Chan) ->
ejabberd_router:route( ejabberd_router:route(
jlib:make_jid( jid:make(
iolist_to_binary( iolist_to_binary(
[Chan, [Chan,
<<"%">>, <<"%">>,
@ -956,7 +956,7 @@ process_num_error(StateData, String) ->
StateData. StateData.
process_endofwhois(StateData, _String, Nick) -> process_endofwhois(StateData, _String, Nick) ->
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Nick, ejabberd_router:route(jid:make(iolist_to_binary([Nick,
<<"!">>, <<"!">>,
StateData#state.server]), StateData#state.server]),
StateData#state.host, <<"">>), StateData#state.host, <<"">>),
@ -973,7 +973,7 @@ process_whois311(StateData, String, Nick, Ident,
Irchost) -> Irchost) ->
Fullname = ejabberd_regexp:replace(String, Fullname = ejabberd_regexp:replace(String,
<<".*311[^:]*:">>, <<"">>), <<".*311[^:]*:">>, <<"">>),
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Nick, ejabberd_router:route(jid:make(iolist_to_binary([Nick,
<<"!">>, <<"!">>,
StateData#state.server]), StateData#state.server]),
StateData#state.host, <<"">>), StateData#state.host, <<"">>),
@ -997,7 +997,7 @@ process_whois311(StateData, String, Nick, Ident,
process_whois312(StateData, String, Nick, Ircserver) -> process_whois312(StateData, String, Nick, Ircserver) ->
Ircserverdesc = ejabberd_regexp:replace(String, Ircserverdesc = ejabberd_regexp:replace(String,
<<".*312[^:]*:">>, <<"">>), <<".*312[^:]*:">>, <<"">>),
ejabberd_router:route(jlib:make_jid(iolist_to_binary([Nick, ejabberd_router:route(jid:make(iolist_to_binary([Nick,
<<"!">>, <<"!">>,
StateData#state.server]), StateData#state.server]),
StateData#state.host, <<"">>), StateData#state.host, <<"">>),
@ -1019,7 +1019,7 @@ process_whois312(StateData, String, Nick, Ircserver) ->
process_whois319(StateData, String, Nick) -> process_whois319(StateData, String, Nick) ->
Chanlist = ejabberd_regexp:replace(String, Chanlist = ejabberd_regexp:replace(String,
<<".*319[^:]*:">>, <<"">>), <<".*319[^:]*:">>, <<"">>),
ejabberd_router:route(jlib:make_jid(iolist_to_binary( ejabberd_router:route(jid:make(iolist_to_binary(
[Nick, [Nick,
<<"!">>, <<"!">>,
StateData#state.server]), StateData#state.server]),
@ -1047,7 +1047,7 @@ process_chanprivmsg(StateData, Chan, From, String) ->
_ -> Msg _ -> Msg
end, end,
Msg2 = filter_message(Msg1), Msg2 = filter_message(Msg1),
ejabberd_router:route(jlib:make_jid(iolist_to_binary( ejabberd_router:route(jid:make(iolist_to_binary(
[Chan, [Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
@ -1069,7 +1069,7 @@ process_channotice(StateData, Chan, From, String) ->
_ -> <<"/me NOTICE: ", Msg/binary>> _ -> <<"/me NOTICE: ", Msg/binary>>
end, end,
Msg2 = filter_message(Msg1), Msg2 = filter_message(Msg1),
ejabberd_router:route(jlib:make_jid(iolist_to_binary( ejabberd_router:route(jid:make(iolist_to_binary(
[Chan, [Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
@ -1091,7 +1091,7 @@ process_privmsg(StateData, _Nick, From, String) ->
_ -> Msg _ -> Msg
end, end,
Msg2 = filter_message(Msg1), Msg2 = filter_message(Msg1),
ejabberd_router:route(jlib:make_jid(iolist_to_binary( ejabberd_router:route(jid:make(iolist_to_binary(
[FromUser, [FromUser,
<<"!">>, <<"!">>,
StateData#state.server]), StateData#state.server]),
@ -1113,7 +1113,7 @@ process_notice(StateData, _Nick, From, String) ->
_ -> <<"/me NOTICE: ", Msg/binary>> _ -> <<"/me NOTICE: ", Msg/binary>>
end, end,
Msg2 = filter_message(Msg1), Msg2 = filter_message(Msg1),
ejabberd_router:route(jlib:make_jid(iolist_to_binary( ejabberd_router:route(jid:make(iolist_to_binary(
[FromUser, [FromUser,
<<"!">>, <<"!">>,
StateData#state.server]), StateData#state.server]),
@ -1141,14 +1141,14 @@ process_userinfo(StateData, _Nick, From) ->
send_text(StateData, send_text(StateData,
io_lib:format("NOTICE ~s :\001USERINFO xmpp:~s\001\r\n", io_lib:format("NOTICE ~s :\001USERINFO xmpp:~s\001\r\n",
[FromUser, [FromUser,
jlib:jid_to_string(StateData#state.user)])). jid:to_string(StateData#state.user)])).
process_topic(StateData, Chan, From, String) -> process_topic(StateData, Chan, From, String) ->
[FromUser | _] = str:tokens(From, <<"!">>), [FromUser | _] = str:tokens(From, <<"!">>),
Msg = ejabberd_regexp:replace(String, Msg = ejabberd_regexp:replace(String,
<<".*TOPIC[^:]*:">>, <<"">>), <<".*TOPIC[^:]*:">>, <<"">>),
Msg1 = filter_message(Msg), Msg1 = filter_message(Msg),
ejabberd_router:route(jlib:make_jid(iolist_to_binary( ejabberd_router:route(jid:make(iolist_to_binary(
[Chan, [Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
@ -1170,7 +1170,7 @@ process_part(StateData, Chan, From, String) ->
Msg = ejabberd_regexp:replace(String, Msg = ejabberd_regexp:replace(String,
<<".*PART[^:]*:">>, <<"">>), <<".*PART[^:]*:">>, <<"">>),
Msg1 = filter_message(Msg), Msg1 = filter_message(Msg),
ejabberd_router:route(jlib:make_jid(iolist_to_binary( ejabberd_router:route(jid:make(iolist_to_binary(
[Chan, [Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
@ -1212,7 +1212,7 @@ process_quit(StateData, From, String) ->
dict:map(fun (Chan, Ps) -> dict:map(fun (Chan, Ps) ->
case (?SETS):is_member(FromUser, Ps) of case (?SETS):is_member(FromUser, Ps) of
true -> true ->
ejabberd_router:route(jlib:make_jid(iolist_to_binary( ejabberd_router:route(jid:make(iolist_to_binary(
[Chan, [Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
@ -1261,7 +1261,7 @@ process_quit(StateData, From, String) ->
process_join(StateData, Channel, From, _String) -> process_join(StateData, Channel, From, _String) ->
[FromUser | FromIdent] = str:tokens(From, <<"!">>), [FromUser | FromIdent] = str:tokens(From, <<"!">>),
[Chan | _] = binary:split(Channel, <<":#">>), [Chan | _] = binary:split(Channel, <<":#">>),
ejabberd_router:route(jlib:make_jid(iolist_to_binary( ejabberd_router:route(jid:make(iolist_to_binary(
[Chan, [Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
@ -1294,7 +1294,7 @@ process_join(StateData, Channel, From, _String) ->
process_mode_o(StateData, Chan, _From, Nick, process_mode_o(StateData, Chan, _From, Nick,
Affiliation, Role) -> Affiliation, Role) ->
ejabberd_router:route(jlib:make_jid(iolist_to_binary( ejabberd_router:route(jid:make(iolist_to_binary(
[Chan, [Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
@ -1318,7 +1318,7 @@ process_kick(StateData, Chan, From, Nick, String) ->
Msg = lists:last(str:tokens(String, <<":">>)), Msg = lists:last(str:tokens(String, <<":">>)),
Msg2 = <<Nick/binary, " kicked by ", From/binary, " (", Msg2 = <<Nick/binary, " kicked by ", From/binary, " (",
(filter_message(Msg))/binary, ")">>, (filter_message(Msg))/binary, ")">>,
ejabberd_router:route(jlib:make_jid(iolist_to_binary( ejabberd_router:route(jid:make(iolist_to_binary(
[Chan, [Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
@ -1329,7 +1329,7 @@ process_kick(StateData, Chan, From, Nick, String) ->
children = children =
[#xmlel{name = <<"body">>, attrs = [], [#xmlel{name = <<"body">>, attrs = [],
children = [{xmlcdata, Msg2}]}]}), children = [{xmlcdata, Msg2}]}]}),
ejabberd_router:route(jlib:make_jid(iolist_to_binary( ejabberd_router:route(jid:make(iolist_to_binary(
[Chan, [Chan,
<<"%">>, <<"%">>,
StateData#state.server]), StateData#state.server]),
@ -1361,7 +1361,7 @@ process_nick(StateData, From, NewNick) ->
NewChans = dict:map(fun (Chan, Ps) -> NewChans = dict:map(fun (Chan, Ps) ->
case (?SETS):is_member(FromUser, Ps) of case (?SETS):is_member(FromUser, Ps) of
true -> true ->
ejabberd_router:route(jlib:make_jid( ejabberd_router:route(jid:make(
iolist_to_binary( iolist_to_binary(
[Chan, [Chan,
<<"%">>, <<"%">>,
@ -1408,7 +1408,7 @@ process_nick(StateData, From, NewNick) ->
children children
= =
[]}]}]}), []}]}]}),
ejabberd_router:route(jlib:make_jid( ejabberd_router:route(jid:make(
iolist_to_binary( iolist_to_binary(
[Chan, [Chan,
<<"%">>, <<"%">>,
@ -1456,7 +1456,7 @@ process_nick(StateData, From, NewNick) ->
process_error(StateData, String) -> process_error(StateData, String) ->
lists:foreach(fun (Chan) -> lists:foreach(fun (Chan) ->
ejabberd_router:route(jlib:make_jid( ejabberd_router:route(jid:make(
iolist_to_binary( iolist_to_binary(
[Chan, [Chan,
<<"%">>, <<"%">>,

View File

@ -236,8 +236,8 @@ on_presence_update(User, Server, _Resource, Status) ->
store_last_info(User, Server, TimeStamp, Status). store_last_info(User, Server, TimeStamp, Status).
store_last_info(User, Server, TimeStamp, Status) -> store_last_info(User, Server, TimeStamp, Status) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
DBType = gen_mod:db_type(LServer, ?MODULE), DBType = gen_mod:db_type(LServer, ?MODULE),
store_last_info(LUser, LServer, TimeStamp, Status, store_last_info(LUser, LServer, TimeStamp, Status,
DBType). DBType).
@ -276,8 +276,8 @@ get_last_info(LUser, LServer) ->
end. end.
remove_user(User, Server) -> remove_user(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
DBType = gen_mod:db_type(LServer, ?MODULE), DBType = gen_mod:db_type(LServer, ?MODULE),
remove_user(LUser, LServer, DBType). remove_user(LUser, LServer, DBType).

View File

@ -136,8 +136,8 @@ stop(Host) ->
ok. ok.
remove_user(User, Server) -> remove_user(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
remove_user(LUser, LServer, remove_user(LUser, LServer,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -199,7 +199,7 @@ user_send_packet(Pkt, C2SState, JID, Peer) ->
muc_filter_message(Pkt, #state{config = Config} = MUCState, muc_filter_message(Pkt, #state{config = Config} = MUCState,
RoomJID, From, FromNick) -> RoomJID, From, FromNick) ->
if Config#config.mam -> if Config#config.mam ->
By = jlib:jid_to_string(RoomJID), By = jid:to_string(RoomJID),
NewPkt = strip_my_archived_tag(Pkt, By), NewPkt = strip_my_archived_tag(Pkt, By),
case store_muc(MUCState, NewPkt, RoomJID, From, FromNick) of case store_muc(MUCState, NewPkt, RoomJID, From, FromNick) of
{ok, ID} -> {ok, ID} ->
@ -323,10 +323,10 @@ process_iq(LServer, From, To, IQ, SubEl, Fs, MsgType) ->
{_, _, _} = jlib:datetime_string_to_timestamp(Data), {_, _, _} = jlib:datetime_string_to_timestamp(Data),
With, RSM}; With, RSM};
({<<"with">>, [Data|_]}, {Start, End, _, RSM}) -> ({<<"with">>, [Data|_]}, {Start, End, _, RSM}) ->
{Start, End, jlib:jid_tolower(jlib:string_to_jid(Data)), RSM}; {Start, End, jid:tolower(jid:from_string(Data)), RSM};
({<<"withroom">>, [Data|_]}, {Start, End, _, RSM}) -> ({<<"withroom">>, [Data|_]}, {Start, End, _, RSM}) ->
{Start, End, {Start, End,
{room, jlib:jid_tolower(jlib:string_to_jid(Data))}, {room, jid:tolower(jid:from_string(Data))},
RSM}; RSM};
({<<"withtext">>, [Data|_]}, {Start, End, _, RSM}) -> ({<<"withtext">>, [Data|_]}, {Start, End, _, RSM}) ->
{Start, End, {text, Data}, RSM}; {Start, End, {text, Data}, RSM};
@ -362,7 +362,7 @@ strip_my_archived_tag(Pkt, LServer) ->
NewEls = lists:filter( NewEls = lists:filter(
fun(#xmlel{name = Tag, attrs = Attrs}) fun(#xmlel{name = Tag, attrs = Attrs})
when Tag == <<"archived">>; Tag == <<"stanza-id">> -> when Tag == <<"archived">>; Tag == <<"stanza-id">> ->
case catch jlib:nameprep( case catch jid:nameprep(
xml:get_attr_s( xml:get_attr_s(
<<"by">>, Attrs)) of <<"by">>, Attrs)) of
LServer -> LServer ->
@ -380,7 +380,7 @@ should_archive_peer(C2SState,
always = Always, always = Always,
never = Never}, never = Never},
Peer) -> Peer) ->
LPeer = jlib:jid_tolower(Peer), LPeer = jid:tolower(Peer),
case lists:member(LPeer, Always) of case lists:member(LPeer, Always) of
true -> true ->
true; true;
@ -423,7 +423,7 @@ store_muc(MUCState, Pkt, RoomJID, Peer, Nick) ->
case should_archive_muc(MUCState, Peer) of case should_archive_muc(MUCState, Peer) of
true -> true ->
LServer = MUCState#state.server_host, LServer = MUCState#state.server_host,
{U, S, _} = jlib:jid_tolower(RoomJID), {U, S, _} = jid:tolower(RoomJID),
store(Pkt, LServer, {U, S}, groupchat, Peer, Nick, recv, store(Pkt, LServer, {U, S}, groupchat, Peer, Nick, recv,
gen_mod:db_type(LServer, ?MODULE)); gen_mod:db_type(LServer, ?MODULE));
false -> false ->
@ -431,7 +431,7 @@ store_muc(MUCState, Pkt, RoomJID, Peer, Nick) ->
end. end.
store(Pkt, _, {LUser, LServer}, Type, Peer, Nick, _Dir, mnesia) -> store(Pkt, _, {LUser, LServer}, Type, Peer, Nick, _Dir, mnesia) ->
LPeer = {PUser, PServer, _} = jlib:jid_tolower(Peer), LPeer = {PUser, PServer, _} = jid:tolower(Peer),
TS = now(), TS = now(),
ID = jlib:integer_to_binary(now_to_usec(TS)), ID = jlib:integer_to_binary(now_to_usec(TS)),
case mnesia:dirty_write( case mnesia:dirty_write(
@ -453,13 +453,13 @@ store(Pkt, LServer, {LUser, LHost}, Type, Peer, Nick, _Dir, odbc) ->
ID = TS = jlib:integer_to_binary(TSinteger), ID = TS = jlib:integer_to_binary(TSinteger),
SUser = case Type of SUser = case Type of
chat -> LUser; chat -> LUser;
groupchat -> jlib:jid_to_string({LUser, LHost, <<>>}) groupchat -> jid:to_string({LUser, LHost, <<>>})
end, end,
BarePeer = jlib:jid_to_string( BarePeer = jid:to_string(
jlib:jid_tolower( jid:tolower(
jlib:jid_remove_resource(Peer))), jid:remove_resource(Peer))),
LPeer = jlib:jid_to_string( LPeer = jid:to_string(
jlib:jid_tolower(Peer)), jid:tolower(Peer)),
XML = xml:element_to_binary(Pkt), XML = xml:element_to_binary(Pkt),
Body = xml:get_subtag_cdata(Pkt, <<"body">>), Body = xml:get_subtag_cdata(Pkt, <<"body">>),
case ejabberd_odbc:sql_query( case ejabberd_odbc:sql_query(
@ -576,7 +576,7 @@ select_and_start(LServer, From, To, Start, End, With, RSM, MsgType, DBType) ->
chat -> chat ->
case With of case With of
{room, {_, _, <<"">>} = WithJID} -> {room, {_, _, <<"">>} = WithJID} ->
select(LServer, jlib:make_jid(WithJID), Start, End, select(LServer, jid:make(WithJID), Start, End,
WithJID, RSM, MsgType, DBType); WithJID, RSM, MsgType, DBType);
_ -> _ ->
select(LServer, From, Start, End, select(LServer, From, Start, End,
@ -639,7 +639,7 @@ select(LServer, #jid{luser = LUser} = JidRequestor,
Start, End, With, RSM, MsgType, {odbc, Host}) -> Start, End, With, RSM, MsgType, {odbc, Host}) ->
User = case MsgType of User = case MsgType of
chat -> LUser; chat -> LUser;
{groupchat, _Role, _MUCState} -> jlib:jid_to_string(JidRequestor) {groupchat, _Role, _MUCState} -> jid:to_string(JidRequestor)
end, end,
{Query, CountQuery} = make_sql_query(User, LServer, {Query, CountQuery} = make_sql_query(User, LServer,
Start, End, With, RSM), Start, End, With, RSM),
@ -670,7 +670,7 @@ select(LServer, #jid{luser = LUser} = JidRequestor,
fun([TS, XML, PeerBin, Kind, Nick]) -> fun([TS, XML, PeerBin, Kind, Nick]) ->
#xmlel{} = El = xml_stream:parse_element(XML), #xmlel{} = El = xml_stream:parse_element(XML),
Now = usec_to_now(jlib:binary_to_integer(TS)), Now = usec_to_now(jlib:binary_to_integer(TS)),
PeerJid = jlib:jid_tolower(jlib:string_to_jid(PeerBin)), PeerJid = jid:tolower(jid:from_string(PeerBin)),
T = if Kind /= <<"">> -> T = if Kind /= <<"">> ->
jlib:binary_to_atom(Kind); jlib:binary_to_atom(Kind);
true -> chat true -> chat
@ -704,9 +704,9 @@ maybe_update_from_to(Pkt, JidRequestor, Peer, chat, _Nick) ->
case xml:get_attr_s(<<"type">>, Pkt#xmlel.attrs) of case xml:get_attr_s(<<"type">>, Pkt#xmlel.attrs) of
<<"groupchat">> when Peer /= undefined -> <<"groupchat">> when Peer /= undefined ->
Pkt2 = xml:replace_tag_attr(<<"to">>, Pkt2 = xml:replace_tag_attr(<<"to">>,
jlib:jid_to_string(JidRequestor), jid:to_string(JidRequestor),
Pkt), Pkt),
xml:replace_tag_attr(<<"from">>, jlib:jid_to_string(Peer), xml:replace_tag_attr(<<"from">>, jid:to_string(Peer),
Pkt2); Pkt2);
_ -> Pkt _ -> Pkt
end; end;
@ -719,12 +719,12 @@ maybe_update_from_to(#xmlel{children = Els} = Pkt, JidRequestor,
children = children =
[#xmlel{name = <<"item">>, [#xmlel{name = <<"item">>,
attrs = [{<<"jid">>, attrs = [{<<"jid">>,
jlib:jid_to_string(Peer)}]}]}]; jid:to_string(Peer)}]}]}];
_ -> _ ->
[] []
end, end,
Pkt1 = Pkt#xmlel{children = Items ++ Els}, Pkt1 = Pkt#xmlel{children = Items ++ Els},
Pkt2 = jlib:replace_from(jlib:jid_replace_resource(JidRequestor, Nick), Pkt1), Pkt2 = jlib:replace_from(jid:replace_resource(JidRequestor, Nick), Pkt1),
jlib:remove_attr(<<"to">>, Pkt2). jlib:remove_attr(<<"to">>, Pkt2).
is_bare_copy(#jid{luser = U, lserver = S, lresource = R}, To) -> is_bare_copy(#jid{luser = U, lserver = S, lresource = R}, To) ->
@ -913,11 +913,11 @@ make_sql_query(User, _LServer, Start, End, With, RSM) ->
ejabberd_odbc:escape(Txt), <<"')">>]; ejabberd_odbc:escape(Txt), <<"')">>];
{_, _, <<>>} -> {_, _, <<>>} ->
[<<" and bare_peer='">>, [<<" and bare_peer='">>,
ejabberd_odbc:escape(jlib:jid_to_string(With)), ejabberd_odbc:escape(jid:to_string(With)),
<<"'">>]; <<"'">>];
{_, _, _} -> {_, _, _} ->
[<<" and peer='">>, [<<" and peer='">>,
ejabberd_odbc:escape(jlib:jid_to_string(With)), ejabberd_odbc:escape(jid:to_string(With)),
<<"'">>]; <<"'">>];
none -> none ->
[] []
@ -991,9 +991,9 @@ datetime_to_now(DateTime, USecs) ->
get_jids(Els) -> get_jids(Els) ->
lists:flatmap( lists:flatmap(
fun(#xmlel{name = <<"jid">>} = El) -> fun(#xmlel{name = <<"jid">>} = El) ->
J = jlib:string_to_jid(xml:get_tag_cdata(El)), J = jid:from_string(xml:get_tag_cdata(El)),
[jlib:jid_tolower(jlib:jid_remove_resource(J)), [jid:tolower(jid:remove_resource(J)),
jlib:jid_tolower(J)]; jid:tolower(J)];
(_) -> (_) ->
[] []
end, Els). end, Els).

View File

@ -84,9 +84,9 @@ s2s_receive_packet(_From, #jid{lserver=LServer}, _Packet) ->
push(LServer, s2s_receive_packet). push(LServer, s2s_receive_packet).
remove_user(_User, Server) -> remove_user(_User, Server) ->
push(jlib:nameprep(Server), remove_user). push(jid:nameprep(Server), remove_user).
register_user(_User, Server) -> register_user(_User, Server) ->
push(jlib:nameprep(Server), register_user). push(jid:nameprep(Server), register_user).
%%==================================================================== %%====================================================================
%% metrics push handler %% metrics push handler

View File

@ -134,7 +134,7 @@ create_room(Host, Name, From, Nick, Opts) ->
gen_server:call(Proc, {create, Name, From, Nick, Opts}). gen_server:call(Proc, {create, Name, From, Nick, Opts}).
store_room(ServerHost, Host, Name, Opts) -> store_room(ServerHost, Host, Name, Opts) ->
LServer = jlib:nameprep(ServerHost), LServer = jid:nameprep(ServerHost),
store_room(LServer, Host, Name, Opts, store_room(LServer, Host, Name, Opts,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -162,7 +162,7 @@ store_room(LServer, Host, Name, Opts, odbc) ->
ejabberd_odbc:sql_transaction(LServer, F). ejabberd_odbc:sql_transaction(LServer, F).
restore_room(ServerHost, Host, Name) -> restore_room(ServerHost, Host, Name) ->
LServer = jlib:nameprep(ServerHost), LServer = jid:nameprep(ServerHost),
restore_room(LServer, Host, Name, restore_room(LServer, Host, Name,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -190,7 +190,7 @@ restore_room(LServer, Host, Name, odbc) ->
end. end.
forget_room(ServerHost, Host, Name) -> forget_room(ServerHost, Host, Name) ->
LServer = jlib:nameprep(ServerHost), LServer = jid:nameprep(ServerHost),
forget_room(LServer, Host, Name, forget_room(LServer, Host, Name,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -216,11 +216,11 @@ forget_room(LServer, Host, Name, odbc) ->
remove_room_mam(LServer, Host, Name) -> remove_room_mam(LServer, Host, Name) ->
case gen_mod:is_loaded(LServer, mod_mam) of case gen_mod:is_loaded(LServer, mod_mam) of
true -> true ->
U = jlib:nodeprep(Name), U = jid:nodeprep(Name),
S = jlib:nameprep(Host), S = jid:nameprep(Host),
DBType = gen_mod:db_type(LServer, mod_mam), DBType = gen_mod:db_type(LServer, mod_mam),
if DBType == odbc -> if DBType == odbc ->
mod_mam:remove_user(jlib:jid_to_string({U, S, <<>>}), mod_mam:remove_user(jid:to_string({U, S, <<>>}),
LServer, DBType); LServer, DBType);
true -> true ->
mod_mam:remove_user(U, S, DBType) mod_mam:remove_user(U, S, DBType)
@ -241,12 +241,12 @@ process_iq_disco_items(Host, From, To,
can_use_nick(_ServerHost, _Host, _JID, <<"">>) -> false; can_use_nick(_ServerHost, _Host, _JID, <<"">>) -> false;
can_use_nick(ServerHost, Host, JID, Nick) -> can_use_nick(ServerHost, Host, JID, Nick) ->
LServer = jlib:nameprep(ServerHost), LServer = jid:nameprep(ServerHost),
can_use_nick(LServer, Host, JID, Nick, can_use_nick(LServer, Host, JID, Nick,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
can_use_nick(_LServer, Host, JID, Nick, mnesia) -> can_use_nick(_LServer, Host, JID, Nick, mnesia) ->
{LUser, LServer, _} = jlib:jid_tolower(JID), {LUser, LServer, _} = jid:tolower(JID),
LUS = {LUser, LServer}, LUS = {LUser, LServer},
case catch mnesia:dirty_select(muc_registered, case catch mnesia:dirty_select(muc_registered,
[{#muc_registered{us_host = '$1', [{#muc_registered{us_host = '$1',
@ -259,7 +259,7 @@ can_use_nick(_LServer, Host, JID, Nick, mnesia) ->
[#muc_registered{us_host = {U, _Host}}] -> U == LUS [#muc_registered{us_host = {U, _Host}}] -> U == LUS
end; end;
can_use_nick(LServer, Host, JID, Nick, riak) -> can_use_nick(LServer, Host, JID, Nick, riak) ->
{LUser, LServer, _} = jlib:jid_tolower(JID), {LUser, LServer, _} = jid:tolower(JID),
LUS = {LUser, LServer}, LUS = {LUser, LServer},
case ejabberd_riak:get_by_index(muc_registered, case ejabberd_riak:get_by_index(muc_registered,
muc_registered_schema(), muc_registered_schema(),
@ -273,7 +273,7 @@ can_use_nick(LServer, Host, JID, Nick, riak) ->
end; end;
can_use_nick(LServer, Host, JID, Nick, odbc) -> can_use_nick(LServer, Host, JID, Nick, odbc) ->
SJID = SJID =
jlib:jid_to_string(jlib:jid_tolower(jlib:jid_remove_resource(JID))), jid:to_string(jid:tolower(jid:remove_resource(JID))),
SNick = ejabberd_odbc:escape(Nick), SNick = ejabberd_odbc:escape(Nick),
SHost = ejabberd_odbc:escape(Host), SHost = ejabberd_odbc:escape(Host),
case catch ejabberd_odbc:sql_query(LServer, case catch ejabberd_odbc:sql_query(LServer,
@ -463,7 +463,7 @@ do_route(Host, ServerHost, Access, HistorySize, RoomShaper,
do_route1(Host, ServerHost, Access, HistorySize, RoomShaper, do_route1(Host, ServerHost, Access, HistorySize, RoomShaper,
From, To, Packet, DefRoomOpts) -> From, To, Packet, DefRoomOpts) ->
{_AccessRoute, AccessCreate, AccessAdmin, _AccessPersistent} = Access, {_AccessRoute, AccessCreate, AccessAdmin, _AccessPersistent} = Access,
{Room, _, Nick} = jlib:jid_tolower(To), {Room, _, Nick} = jid:tolower(To),
#xmlel{name = Name, attrs = Attrs} = Packet, #xmlel{name = Name, attrs = Attrs} = Packet,
case Room of case Room of
<<"">> -> <<"">> ->
@ -641,7 +641,7 @@ check_user_can_create_room(ServerHost, AccessCreate,
end. end.
get_rooms(ServerHost, Host) -> get_rooms(ServerHost, Host) ->
LServer = jlib:nameprep(ServerHost), LServer = jid:nameprep(ServerHost),
get_rooms(LServer, Host, get_rooms(LServer, Host,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -767,7 +767,7 @@ iq_disco_items(Host, From, Lang, none) ->
#xmlel{name = <<"item">>, #xmlel{name = <<"item">>,
attrs = attrs =
[{<<"jid">>, [{<<"jid">>,
jlib:jid_to_string({Name, Host, jid:to_string({Name, Host,
<<"">>})}, <<"">>})},
{<<"name">>, Desc}], {<<"name">>, Desc}],
children = []}}; children = []}};
@ -791,7 +791,7 @@ iq_disco_items(Host, From, Lang, Rsm) ->
#xmlel{name = <<"item">>, #xmlel{name = <<"item">>,
attrs = attrs =
[{<<"jid">>, [{<<"jid">>,
jlib:jid_to_string({Name, Host, jid:to_string({Name, Host,
<<"">>})}, <<"">>})},
{<<"name">>, Desc}], {<<"name">>, Desc}],
children = []}}; children = []}};
@ -868,12 +868,12 @@ iq_get_unique(From) ->
randoms:get_string()]))}. randoms:get_string()]))}.
get_nick(ServerHost, Host, From) -> get_nick(ServerHost, Host, From) ->
LServer = jlib:nameprep(ServerHost), LServer = jid:nameprep(ServerHost),
get_nick(LServer, Host, From, get_nick(LServer, Host, From,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
get_nick(_LServer, Host, From, mnesia) -> get_nick(_LServer, Host, From, mnesia) ->
{LUser, LServer, _} = jlib:jid_tolower(From), {LUser, LServer, _} = jid:tolower(From),
LUS = {LUser, LServer}, LUS = {LUser, LServer},
case catch mnesia:dirty_read(muc_registered, case catch mnesia:dirty_read(muc_registered,
{LUS, Host}) {LUS, Host})
@ -883,7 +883,7 @@ get_nick(_LServer, Host, From, mnesia) ->
[#muc_registered{nick = Nick}] -> Nick [#muc_registered{nick = Nick}] -> Nick
end; end;
get_nick(LServer, Host, From, riak) -> get_nick(LServer, Host, From, riak) ->
{LUser, LServer, _} = jlib:jid_tolower(From), {LUser, LServer, _} = jid:tolower(From),
US = {LUser, LServer}, US = {LUser, LServer},
case ejabberd_riak:get(muc_registered, case ejabberd_riak:get(muc_registered,
muc_registered_schema(), muc_registered_schema(),
@ -893,7 +893,7 @@ get_nick(LServer, Host, From, riak) ->
end; end;
get_nick(LServer, Host, From, odbc) -> get_nick(LServer, Host, From, odbc) ->
SJID = SJID =
ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(jlib:jid_remove_resource(From)))), ejabberd_odbc:escape(jid:to_string(jid:tolower(jid:remove_resource(From)))),
SHost = ejabberd_odbc:escape(Host), SHost = ejabberd_odbc:escape(Host),
case catch ejabberd_odbc:sql_query(LServer, case catch ejabberd_odbc:sql_query(LServer,
[<<"select nick from muc_registered where " [<<"select nick from muc_registered where "
@ -941,12 +941,12 @@ iq_get_register_info(ServerHost, Host, From, Lang) ->
Nick)]}]. Nick)]}].
set_nick(ServerHost, Host, From, Nick) -> set_nick(ServerHost, Host, From, Nick) ->
LServer = jlib:nameprep(ServerHost), LServer = jid:nameprep(ServerHost),
set_nick(LServer, Host, From, Nick, set_nick(LServer, Host, From, Nick,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
set_nick(_LServer, Host, From, Nick, mnesia) -> set_nick(_LServer, Host, From, Nick, mnesia) ->
{LUser, LServer, _} = jlib:jid_tolower(From), {LUser, LServer, _} = jid:tolower(From),
LUS = {LUser, LServer}, LUS = {LUser, LServer},
F = fun () -> F = fun () ->
case Nick of case Nick of
@ -976,7 +976,7 @@ set_nick(_LServer, Host, From, Nick, mnesia) ->
end, end,
mnesia:transaction(F); mnesia:transaction(F);
set_nick(LServer, Host, From, Nick, riak) -> set_nick(LServer, Host, From, Nick, riak) ->
{LUser, LServer, _} = jlib:jid_tolower(From), {LUser, LServer, _} = jid:tolower(From),
LUS = {LUser, LServer}, LUS = {LUser, LServer},
{atomic, {atomic,
case Nick of case Nick of
@ -1006,7 +1006,7 @@ set_nick(LServer, Host, From, Nick, riak) ->
end}; end};
set_nick(LServer, Host, From, Nick, odbc) -> set_nick(LServer, Host, From, Nick, odbc) ->
JID = JID =
jlib:jid_to_string(jlib:jid_tolower(jlib:jid_remove_resource(From))), jid:to_string(jid:tolower(jid:remove_resource(From))),
SJID = ejabberd_odbc:escape(JID), SJID = ejabberd_odbc:escape(JID),
SNick = ejabberd_odbc:escape(Nick), SNick = ejabberd_odbc:escape(Nick),
SHost = ejabberd_odbc:escape(Host), SHost = ejabberd_odbc:escape(Host),
@ -1255,8 +1255,8 @@ export(_Server) ->
case str:suffix(Host, RoomHost) of case str:suffix(Host, RoomHost) of
true -> true ->
SJID = ejabberd_odbc:escape( SJID = ejabberd_odbc:escape(
jlib:jid_to_string( jid:to_string(
jlib:make_jid(U, S, <<"">>))), jid:make(U, S, <<"">>))),
SNick = ejabberd_odbc:escape(Nick), SNick = ejabberd_odbc:escape(Nick),
SRoomHost = ejabberd_odbc:escape(RoomHost), SRoomHost = ejabberd_odbc:escape(RoomHost),
[[<<"delete from muc_registered where jid='">>, [[<<"delete from muc_registered where jid='">>,
@ -1279,7 +1279,7 @@ import(_LServer) ->
{<<"select jid, host, nick from muc_registered;">>, {<<"select jid, host, nick from muc_registered;">>,
fun([J, RoomHost, Nick]) -> fun([J, RoomHost, Nick]) ->
#jid{user = U, server = S} = #jid{user = U, server = S} =
jlib:string_to_jid(J), jid:from_string(J),
#muc_registered{us_host = {{U, S}, RoomHost}, #muc_registered{us_host = {{U, S}, RoomHost},
nick = Nick} nick = Nick}
end}]. end}].

View File

@ -676,7 +676,7 @@ get_room_occupants(Pid) ->
S = get_room_state(Pid), S = get_room_state(Pid),
lists:map( lists:map(
fun({_LJID, Info}) -> fun({_LJID, Info}) ->
{jlib:jid_to_string(Info#user.jid), {jid:to_string(Info#user.jid),
Info#user.nick, Info#user.nick,
atom_to_list(Info#user.role)} atom_to_list(Info#user.role)}
end, end,
@ -691,11 +691,11 @@ get_room_occupants_number(Room, Host) ->
%% http://xmpp.org/extensions/xep-0249.html %% http://xmpp.org/extensions/xep-0249.html
send_direct_invitation(RoomName, RoomService, Password, Reason, UsersString) -> send_direct_invitation(RoomName, RoomService, Password, Reason, UsersString) ->
RoomJid = jlib:make_jid(RoomName, RoomService, <<"">>), RoomJid = jid:make(RoomName, RoomService, <<"">>),
RoomString = jlib:jid_to_string(RoomJid), RoomString = jid:to_string(RoomJid),
XmlEl = build_invitation(Password, Reason, RoomString), XmlEl = build_invitation(Password, Reason, RoomString),
UsersStrings = get_users_to_invite(RoomJid, binary_to_list(UsersString)), UsersStrings = get_users_to_invite(RoomJid, binary_to_list(UsersString)),
[send_direct_invitation(RoomJid, jlib:string_to_jid(list_to_binary(UserStrings)), XmlEl) [send_direct_invitation(RoomJid, jid:from_string(list_to_binary(UserStrings)), XmlEl)
|| UserStrings <- UsersStrings], || UserStrings <- UsersStrings],
timer:sleep(1000), timer:sleep(1000),
ok. ok.
@ -704,11 +704,11 @@ get_users_to_invite(RoomJid, UsersString) ->
UsersStrings = string:tokens(UsersString, ":"), UsersStrings = string:tokens(UsersString, ":"),
OccupantsTuples = get_room_occupants(RoomJid#jid.luser, OccupantsTuples = get_room_occupants(RoomJid#jid.luser,
RoomJid#jid.lserver), RoomJid#jid.lserver),
OccupantsJids = [jlib:string_to_jid(JidString) OccupantsJids = [jid:from_string(JidString)
|| {JidString, _Nick, _} <- OccupantsTuples], || {JidString, _Nick, _} <- OccupantsTuples],
lists:filter( lists:filter(
fun(UserString) -> fun(UserString) ->
UserJid = jlib:string_to_jid(list_to_binary(UserString)), UserJid = jid:from_string(list_to_binary(UserString)),
%% [{"badlop@localhost/work","badlop","moderator"}] %% [{"badlop@localhost/work","badlop","moderator"}]
lists:all(fun(OccupantJid) -> lists:all(fun(OccupantJid) ->
UserJid#jid.luser /= OccupantJid#jid.luser UserJid#jid.luser /= OccupantJid#jid.luser
@ -872,7 +872,7 @@ set_room_affiliation(Name, Service, JID, AffiliationString) ->
[R] -> [R] ->
%% Get the PID for the online room so we can get the state of the room %% Get the PID for the online room so we can get the state of the room
Pid = R#muc_online_room.pid, Pid = R#muc_online_room.pid,
{ok, StateData} = gen_fsm:sync_send_all_state_event(Pid, {process_item_change, {jlib:string_to_jid(JID), affiliation, Affiliation, <<"">>}, <<"">>}), {ok, StateData} = gen_fsm:sync_send_all_state_event(Pid, {process_item_change, {jid:from_string(JID), affiliation, Affiliation, <<"">>}, <<"">>}),
mod_muc:store_room(StateData#state.server_host, StateData#state.host, StateData#state.room, make_opts(StateData)), mod_muc:store_room(StateData#state.server_host, StateData#state.host, StateData#state.room, make_opts(StateData)),
ok; ok;
[] -> [] ->

View File

@ -279,7 +279,7 @@ build_filename_string(TimeStamp, OutDir, RoomJID,
{Fd, Fn, Fnrel}. {Fd, Fn, Fnrel}.
get_room_name(RoomJID) -> get_room_name(RoomJID) ->
JID = jlib:string_to_jid(RoomJID), JID#jid.user. JID = jid:from_string(RoomJID), JID#jid.user.
%% calculate day before %% calculate day before
get_timestamp_daydiff(TimeStamp, Daydiff) -> get_timestamp_daydiff(TimeStamp, Daydiff) ->
@ -999,7 +999,7 @@ get_room_info(RoomJID, Opts) ->
{value, {_, SA}} -> SA; {value, {_, SA}} -> SA;
false -> <<"">> false -> <<"">>
end, end,
#room{jid = jlib:jid_to_string(RoomJID), title = Title, #room{jid = jid:to_string(RoomJID), title = Title,
subject = Subject, subject_author = SubjectAuthor, subject = Subject, subject_author = SubjectAuthor,
config = Opts}. config = Opts}.
@ -1160,7 +1160,7 @@ role_users_to_string(RoleS, Users) ->
<<RoleS/binary, ": ", UsersString/binary>>. <<RoleS/binary, ": ", UsersString/binary>>.
get_room_occupants(RoomJIDString) -> get_room_occupants(RoomJIDString) ->
RoomJID = jlib:string_to_jid(RoomJIDString), RoomJID = jid:from_string(RoomJIDString),
RoomName = RoomJID#jid.luser, RoomName = RoomJID#jid.luser,
MucService = RoomJID#jid.lserver, MucService = RoomJID#jid.lserver,
StateData = get_room_state(RoomName, MucService), StateData = get_room_state(RoomName, MucService),

View File

@ -107,7 +107,7 @@ init([Host, ServerHost, Access, Room, HistorySize,
#state{host = Host, server_host = ServerHost, #state{host = Host, server_host = ServerHost,
access = Access, room = Room, access = Access, room = Room,
history = lqueue_new(HistorySize), history = lqueue_new(HistorySize),
jid = jlib:make_jid(Room, Host, <<"">>), jid = jid:make(Room, Host, <<"">>),
just_created = true, just_created = true,
room_shaper = Shaper}), room_shaper = Shaper}),
State1 = set_opts(DefRoomOpts, State), State1 = set_opts(DefRoomOpts, State),
@ -119,7 +119,7 @@ init([Host, ServerHost, Access, Room, HistorySize,
true -> ok true -> ok
end, end,
?INFO_MSG("Created MUC room ~s@~s by ~s", ?INFO_MSG("Created MUC room ~s@~s by ~s",
[Room, Host, jlib:jid_to_string(Creator)]), [Room, Host, jid:to_string(Creator)]),
add_to_log(room_existence, created, State1), add_to_log(room_existence, created, State1),
add_to_log(room_existence, started, State1), add_to_log(room_existence, started, State1),
{ok, normal_state, State1}; {ok, normal_state, State1};
@ -131,7 +131,7 @@ init([Host, ServerHost, Access, Room, HistorySize, RoomShaper, Opts]) ->
access = Access, access = Access,
room = Room, room = Room,
history = lqueue_new(HistorySize), history = lqueue_new(HistorySize),
jid = jlib:make_jid(Room, Host, <<"">>), jid = jid:make(Room, Host, <<"">>),
room_shaper = Shaper}), room_shaper = Shaper}),
add_to_log(room_existence, started, State), add_to_log(room_existence, started, State),
{ok, normal_state, State}. {ok, normal_state, State}.
@ -287,7 +287,7 @@ normal_state({route, From, <<"">>,
MinInterval = MinInterval =
(StateData#state.config)#config.voice_request_min_interval, (StateData#state.config)#config.voice_request_min_interval,
BareFrom = BareFrom =
jlib:jid_remove_resource(jlib:jid_tolower(From)), jid:remove_resource(jid:tolower(From)),
NowPriority = -now_to_usec(now()), NowPriority = -now_to_usec(now()),
CleanPriority = NowPriority + CleanPriority = NowPriority +
MinInterval * MinInterval *
@ -533,7 +533,7 @@ normal_state({route, From, ToNick,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_BAD_REQUEST(Lang, ?ERRT_BAD_REQUEST(Lang,
ErrText)), ErrText)),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
ToNick), ToNick),
From, Err); From, Err);
_ -> _ ->
@ -544,7 +544,7 @@ normal_state({route, From, ToNick,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_ITEM_NOT_FOUND(Lang, ?ERRT_ITEM_NOT_FOUND(Lang,
ErrText)), ErrText)),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
ToNick), ToNick),
From, Err); From, Err);
ToJIDs -> ToJIDs ->
@ -558,10 +558,10 @@ normal_state({route, From, ToNick,
(PmFromVisitors == moderators) and (PmFromVisitors == moderators) and
DstIsModerator -> DstIsModerator ->
{ok, #user{nick = FromNick}} = {ok, #user{nick = FromNick}} =
(?DICT):find(jlib:jid_tolower(From), (?DICT):find(jid:tolower(From),
StateData#state.users), StateData#state.users),
FromNickJID = FromNickJID =
jlib:jid_replace_resource(StateData#state.jid, jid:replace_resource(StateData#state.jid,
FromNick), FromNick),
X = #xmlel{name = <<"x">>, X = #xmlel{name = <<"x">>,
attrs = [{<<"xmlns">>, ?NS_MUC_USER}]}, attrs = [{<<"xmlns">>, ?NS_MUC_USER}]},
@ -574,7 +574,7 @@ normal_state({route, From, ToNick,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_FORBIDDEN(Lang, ?ERRT_FORBIDDEN(Lang,
ErrText)), ErrText)),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
ToNick), ToNick),
From, Err) From, Err)
end end
@ -587,7 +587,7 @@ normal_state({route, From, ToNick,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_NOT_ACCEPTABLE(Lang, ?ERRT_NOT_ACCEPTABLE(Lang,
ErrText)), ErrText)),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
ToNick), ToNick),
From, Err); From, Err);
{false, _} -> {false, _} ->
@ -595,7 +595,7 @@ normal_state({route, From, ToNick,
<<"It is not allowed to send private messages">>, <<"It is not allowed to send private messages">>,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_FORBIDDEN(Lang, ErrText)), ?ERRT_FORBIDDEN(Lang, ErrText)),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
ToNick), ToNick),
From, Err) From, Err)
end, end,
@ -619,17 +619,17 @@ normal_state({route, From, ToNick,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_ITEM_NOT_FOUND(Lang, ?ERRT_ITEM_NOT_FOUND(Lang,
ErrText)), ErrText)),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
ToNick), ToNick),
From, Err) From, Err)
end; end;
ToJID -> ToJID ->
{ok, #user{nick = FromNick}} = {ok, #user{nick = FromNick}} =
(?DICT):find(jlib:jid_tolower(FromFull), (?DICT):find(jid:tolower(FromFull),
StateData#state.users), StateData#state.users),
{ToJID2, Packet2} = handle_iq_vcard(FromFull, ToJID, {ToJID2, Packet2} = handle_iq_vcard(FromFull, ToJID,
StanzaId, NewId, Packet), StanzaId, NewId, Packet),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
FromNick), FromNick),
ToJID2, Packet2) ToJID2, Packet2)
end; end;
@ -643,7 +643,7 @@ normal_state({route, From, ToNick,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_NOT_ACCEPTABLE(Lang, ?ERRT_NOT_ACCEPTABLE(Lang,
ErrText)), ErrText)),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
ToNick), ToNick),
From, Err) From, Err)
end; end;
@ -655,7 +655,7 @@ normal_state({route, From, ToNick,
"not allowed in this room">>, "not allowed in this room">>,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_NOT_ALLOWED(Lang, ErrText)), ?ERRT_NOT_ALLOWED(Lang, ErrText)),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
ToNick), ToNick),
From, Err) From, Err)
end end
@ -698,12 +698,12 @@ handle_event({destroy, Reason}, _StateName,
end}, end},
StateData), StateData),
?INFO_MSG("Destroyed MUC room ~s with reason: ~p", ?INFO_MSG("Destroyed MUC room ~s with reason: ~p",
[jlib:jid_to_string(StateData#state.jid), Reason]), [jid:to_string(StateData#state.jid), Reason]),
add_to_log(room_existence, destroyed, StateData), add_to_log(room_existence, destroyed, StateData),
{stop, shutdown, StateData}; {stop, shutdown, StateData};
handle_event(destroy, StateName, StateData) -> handle_event(destroy, StateName, StateData) ->
?INFO_MSG("Destroyed MUC room ~s", ?INFO_MSG("Destroyed MUC room ~s",
[jlib:jid_to_string(StateData#state.jid)]), [jid:to_string(StateData#state.jid)]),
handle_event({destroy, none}, StateName, StateData); handle_event({destroy, none}, StateName, StateData);
handle_event({set_affiliations, Affiliations}, handle_event({set_affiliations, Affiliations},
StateName, StateData) -> StateName, StateData) ->
@ -807,7 +807,7 @@ handle_info({captcha_failed, From}, normal_state,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERR_NOT_AUTHORIZED), ?ERR_NOT_AUTHORIZED),
ejabberd_router:route % TODO: s/Nick/""/ ejabberd_router:route % TODO: s/Nick/""/
(jlib:jid_replace_resource(StateData#state.jid, (jid:replace_resource(StateData#state.jid,
Nick), Nick),
From, Err), From, Err),
StateData#state{robots = Robots}; StateData#state{robots = Robots};
@ -848,7 +848,7 @@ terminate(Reason, _StateName, StateData) ->
Nick = Info#user.nick, Nick = Info#user.nick,
case Reason of case Reason of
shutdown -> shutdown ->
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
Nick), Nick),
Info#user.jid, Packet); Info#user.jid, Packet);
_ -> ok _ -> ok
@ -924,7 +924,7 @@ process_groupchat_message(From,
{next_state, normal_state, StateData}; {next_state, normal_state, StateData};
NewPacket1 -> NewPacket1 ->
NewPacket = xml:remove_subtags(NewPacket1, <<"nick">>, {<<"xmlns">>, ?NS_NICK}), NewPacket = xml:remove_subtags(NewPacket1, <<"nick">>, {<<"xmlns">>, ?NS_NICK}),
send_multiple(jlib:jid_replace_resource(StateData#state.jid, send_multiple(jid:replace_resource(StateData#state.jid,
FromNick), FromNick),
StateData#state.server_host, StateData#state.server_host,
StateData#state.users, StateData#state.users,
@ -992,7 +992,7 @@ is_user_allowed_message_nonparticipant(JID,
%% @doc Get information of this participant, or default values. %% @doc Get information of this participant, or default values.
%% If the JID is not a participant, return values for a service message. %% If the JID is not a participant, return values for a service message.
get_participant_data(From, StateData) -> get_participant_data(From, StateData) ->
case (?DICT):find(jlib:jid_tolower(From), case (?DICT):find(jid:tolower(From),
StateData#state.users) StateData#state.users)
of of
{ok, #user{nick = FromNick, role = Role}} -> {ok, #user{nick = FromNick, role = Role}} ->
@ -1069,7 +1069,7 @@ process_presence(From, Nick,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_NOT_ALLOWED(Lang, ?ERRT_NOT_ALLOWED(Lang,
ErrText)), ErrText)),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
Nick), Nick),
From, Err), From, Err),
StateData; StateData;
@ -1082,7 +1082,7 @@ process_presence(From, Nick,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_CONFLICT(Lang, ?ERRT_CONFLICT(Lang,
ErrText)), ErrText)),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
Nick), % TODO: s/Nick/""/ Nick), % TODO: s/Nick/""/
From, Err), From, Err),
StateData; StateData;
@ -1093,7 +1093,7 @@ process_presence(From, Nick,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_CONFLICT(Lang, ?ERRT_CONFLICT(Lang,
ErrText)), ErrText)),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
Nick), Nick),
From, Err), From, Err),
StateData; StateData;
@ -1129,14 +1129,14 @@ close_room_if_temporary_and_empty(StateData1) ->
true -> true ->
?INFO_MSG("Destroyed MUC room ~s because it's temporary " ?INFO_MSG("Destroyed MUC room ~s because it's temporary "
"and empty", "and empty",
[jlib:jid_to_string(StateData1#state.jid)]), [jid:to_string(StateData1#state.jid)]),
add_to_log(room_existence, destroyed, StateData1), add_to_log(room_existence, destroyed, StateData1),
{stop, normal, StateData1}; {stop, normal, StateData1};
_ -> {next_state, normal_state, StateData1} _ -> {next_state, normal_state, StateData1}
end. end.
is_user_online(JID, StateData) -> is_user_online(JID, StateData) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
(?DICT):is_key(LJID, StateData#state.users). (?DICT):is_key(LJID, StateData#state.users).
%% Check if the user is occupant of the room, or at least is an admin or owner. %% Check if the user is occupant of the room, or at least is an admin or owner.
@ -1161,7 +1161,7 @@ is_user_online_iq(StanzaId, JID, StateData)
when JID#jid.lresource == <<"">> -> when JID#jid.lresource == <<"">> ->
try stanzaid_unpack(StanzaId) of try stanzaid_unpack(StanzaId) of
{OriginalId, Resource} -> {OriginalId, Resource} ->
JIDWithResource = jlib:jid_replace_resource(JID, JIDWithResource = jid:replace_resource(JID,
Resource), Resource),
{is_user_online(JIDWithResource, StateData), OriginalId, {is_user_online(JIDWithResource, StateData), OriginalId,
JIDWithResource} JIDWithResource}
@ -1171,7 +1171,7 @@ is_user_online_iq(StanzaId, JID, StateData)
handle_iq_vcard(FromFull, ToJID, StanzaId, NewId, handle_iq_vcard(FromFull, ToJID, StanzaId, NewId,
Packet) -> Packet) ->
ToBareJID = jlib:jid_remove_resource(ToJID), ToBareJID = jid:remove_resource(ToJID),
IQ = jlib:iq_query_info(Packet), IQ = jlib:iq_query_info(Packet),
handle_iq_vcard2(FromFull, ToJID, ToBareJID, StanzaId, handle_iq_vcard2(FromFull, ToJID, ToBareJID, StanzaId,
NewId, IQ, Packet). NewId, IQ, Packet).
@ -1253,7 +1253,7 @@ decide_fate_message(<<"error">>, Packet, From,
Reason = Reason =
io_lib:format("This participant is considered a ghost " io_lib:format("This participant is considered a ghost "
"and is expulsed: ~s", "and is expulsed: ~s",
[jlib:jid_to_string(From)]), [jid:to_string(From)]),
{expulse_sender, Reason}; {expulse_sender, Reason};
false -> continue_delivery false -> continue_delivery
end, end,
@ -1324,7 +1324,7 @@ set_affiliation(JID, Affiliation, StateData) ->
set_affiliation(JID, Affiliation, StateData, <<"">>). set_affiliation(JID, Affiliation, StateData, <<"">>).
set_affiliation(JID, Affiliation, StateData, Reason) -> set_affiliation(JID, Affiliation, StateData, Reason) ->
LJID = jlib:jid_remove_resource(jlib:jid_tolower(JID)), LJID = jid:remove_resource(jid:tolower(JID)),
Affiliations = case Affiliation of Affiliations = case Affiliation of
none -> none ->
(?DICT):erase(LJID, StateData#state.affiliations); (?DICT):erase(LJID, StateData#state.affiliations);
@ -1343,11 +1343,11 @@ get_affiliation(JID, StateData) ->
of of
allow -> owner; allow -> owner;
_ -> _ ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
case (?DICT):find(LJID, StateData#state.affiliations) of case (?DICT):find(LJID, StateData#state.affiliations) of
{ok, Affiliation} -> Affiliation; {ok, Affiliation} -> Affiliation;
_ -> _ ->
LJID1 = jlib:jid_remove_resource(LJID), LJID1 = jid:remove_resource(LJID),
case (?DICT):find(LJID1, StateData#state.affiliations) case (?DICT):find(LJID1, StateData#state.affiliations)
of of
{ok, Affiliation} -> Affiliation; {ok, Affiliation} -> Affiliation;
@ -1358,7 +1358,7 @@ get_affiliation(JID, StateData) ->
of of
{ok, Affiliation} -> Affiliation; {ok, Affiliation} -> Affiliation;
_ -> _ ->
LJID3 = jlib:jid_remove_resource(LJID2), LJID3 = jid:remove_resource(LJID2),
case (?DICT):find(LJID3, case (?DICT):find(LJID3,
StateData#state.affiliations) StateData#state.affiliations)
of of
@ -1386,7 +1386,7 @@ get_service_affiliation(JID, StateData) ->
end. end.
set_role(JID, Role, StateData) -> set_role(JID, Role, StateData) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
LJIDs = case LJID of LJIDs = case LJID of
{U, S, <<"">>} -> {U, S, <<"">>} ->
(?DICT):fold(fun (J, _, Js) -> (?DICT):fold(fun (J, _, Js) ->
@ -1433,7 +1433,7 @@ set_role(JID, Role, StateData) ->
StateData#state{users = Users, nicks = Nicks}. StateData#state{users = Users, nicks = Nicks}.
get_role(JID, StateData) -> get_role(JID, StateData) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
case (?DICT):find(LJID, StateData#state.users) of case (?DICT):find(LJID, StateData#state.users) of
{ok, #user{role = Role}} -> Role; {ok, #user{role = Role}} -> Role;
_ -> none _ -> none
@ -1483,7 +1483,7 @@ get_max_users_admin_threshold(StateData) ->
5). 5).
get_user_activity(JID, StateData) -> get_user_activity(JID, StateData) ->
case treap:lookup(jlib:jid_tolower(JID), case treap:lookup(jid:tolower(JID),
StateData#state.activity) StateData#state.activity)
of of
{ok, _P, A} -> A; {ok, _P, A} -> A;
@ -1515,7 +1515,7 @@ store_user_activity(JID, UserActivity, StateData) ->
fun(I) when is_number(I), I>=0 -> I end, fun(I) when is_number(I), I>=0 -> I end,
0) 0)
* 1000), * 1000),
Key = jlib:jid_tolower(JID), Key = jid:tolower(JID),
Now = now_to_usec(now()), Now = now_to_usec(now()),
Activity1 = clean_treap(StateData#state.activity, Activity1 = clean_treap(StateData#state.activity,
{1, -Now}), {1, -Now}),
@ -1598,7 +1598,7 @@ prepare_room_queue(StateData) ->
end. end.
add_online_user(JID, Nick, Role, StateData) -> add_online_user(JID, Nick, Role, StateData) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
Users = (?DICT):store(LJID, Users = (?DICT):store(LJID,
#user{jid = JID, nick = Nick, role = Role}, #user{jid = JID, nick = Nick, role = Role},
StateData#state.users), StateData#state.users),
@ -1618,7 +1618,7 @@ remove_online_user(JID, StateData) ->
remove_online_user(JID, StateData, <<"">>). remove_online_user(JID, StateData, <<"">>).
remove_online_user(JID, StateData, Reason) -> remove_online_user(JID, StateData, Reason) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
{ok, #user{nick = Nick}} = (?DICT):find(LJID, {ok, #user{nick = Nick}} = (?DICT):find(LJID,
StateData#state.users), StateData#state.users),
add_to_log(leave, {Nick, Reason}, StateData), add_to_log(leave, {Nick, Reason}, StateData),
@ -1667,7 +1667,7 @@ strip_status(#xmlel{name = <<"presence">>,
children = FEls}. children = FEls}.
add_user_presence(JID, Presence, StateData) -> add_user_presence(JID, Presence, StateData) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
FPresence = filter_presence(Presence), FPresence = filter_presence(Presence),
Users = (?DICT):update(LJID, Users = (?DICT):update(LJID,
fun (#user{} = User) -> fun (#user{} = User) ->
@ -1677,7 +1677,7 @@ add_user_presence(JID, Presence, StateData) ->
StateData#state{users = Users}. StateData#state{users = Users}.
add_user_presence_un(JID, Presence, StateData) -> add_user_presence_un(JID, Presence, StateData) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
FPresence = filter_presence(Presence), FPresence = filter_presence(Presence),
Users = (?DICT):update(LJID, Users = (?DICT):update(LJID,
fun (#user{} = User) -> fun (#user{} = User) ->
@ -1691,8 +1691,8 @@ add_user_presence_un(JID, Presence, StateData) ->
%% Return jid record. %% Return jid record.
find_jids_by_nick(Nick, StateData) -> find_jids_by_nick(Nick, StateData) ->
case (?DICT):find(Nick, StateData#state.nicks) of case (?DICT):find(Nick, StateData#state.nicks) of
{ok, [User]} -> [jlib:make_jid(User)]; {ok, [User]} -> [jid:make(User)];
{ok, Users} -> [jlib:make_jid(LJID) || LJID <- Users]; {ok, Users} -> [jid:make(LJID) || LJID <- Users];
error -> false error -> false
end. end.
@ -1700,7 +1700,7 @@ find_jids_by_nick(Nick, StateData) ->
%% highest-priority presence. Return jid record. %% highest-priority presence. Return jid record.
find_jid_by_nick(Nick, StateData) -> find_jid_by_nick(Nick, StateData) ->
case (?DICT):find(Nick, StateData#state.nicks) of case (?DICT):find(Nick, StateData#state.nicks) of
{ok, [User]} -> jlib:make_jid(User); {ok, [User]} -> jid:make(User);
{ok, [FirstUser | Users]} -> {ok, [FirstUser | Users]} ->
#user{last_presence = FirstPresence} = #user{last_presence = FirstPresence} =
(?DICT):fetch(FirstUser, StateData#state.users), (?DICT):fetch(FirstUser, StateData#state.users),
@ -1718,7 +1718,7 @@ find_jid_by_nick(Nick, StateData) ->
end end
end, end,
{FirstUser, FirstPresence}, Users), {FirstUser, FirstPresence}, Users),
jlib:make_jid(LJID); jid:make(LJID);
error -> false error -> false
end. end.
@ -1748,7 +1748,7 @@ find_nick_by_jid(Jid, StateData) ->
Nick. Nick.
is_nick_change(JID, Nick, StateData) -> is_nick_change(JID, Nick, StateData) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
case Nick of case Nick of
<<"">> -> false; <<"">> -> false;
_ -> _ ->
@ -1760,8 +1760,8 @@ is_nick_change(JID, Nick, StateData) ->
nick_collision(User, Nick, StateData) -> nick_collision(User, Nick, StateData) ->
UserOfNick = find_jid_by_nick(Nick, StateData), UserOfNick = find_jid_by_nick(Nick, StateData),
(UserOfNick /= false andalso (UserOfNick /= false andalso
jlib:jid_remove_resource(jlib:jid_tolower(UserOfNick)) jid:remove_resource(jid:tolower(UserOfNick))
/= jlib:jid_remove_resource(jlib:jid_tolower(User))). /= jid:remove_resource(jid:tolower(User))).
add_new_user(From, Nick, add_new_user(From, Nick,
#xmlel{attrs = Attrs, children = Els} = Packet, #xmlel{attrs = Attrs, children = Els} = Packet,
@ -1796,7 +1796,7 @@ add_new_user(From, Nick,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERR_SERVICE_UNAVAILABLE), ?ERR_SERVICE_UNAVAILABLE),
ejabberd_router:route % TODO: s/Nick/""/ ejabberd_router:route % TODO: s/Nick/""/
(jlib:jid_replace_resource(StateData#state.jid, Nick), (jid:replace_resource(StateData#state.jid, Nick),
From, Err), From, Err),
StateData; StateData;
{_, _, _, none} -> {_, _, _, none} ->
@ -1813,14 +1813,14 @@ add_new_user(From, Nick,
ErrText) ErrText)
end), end),
ejabberd_router:route % TODO: s/Nick/""/ ejabberd_router:route % TODO: s/Nick/""/
(jlib:jid_replace_resource(StateData#state.jid, Nick), (jid:replace_resource(StateData#state.jid, Nick),
From, Err), From, Err),
StateData; StateData;
{_, true, _, _} -> {_, true, _, _} ->
ErrText = <<"That nickname is already in use by another occupant">>, ErrText = <<"That nickname is already in use by another occupant">>,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_CONFLICT(Lang, ErrText)), ?ERRT_CONFLICT(Lang, ErrText)),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
Nick), Nick),
From, Err), From, Err),
StateData; StateData;
@ -1828,7 +1828,7 @@ add_new_user(From, Nick,
ErrText = <<"That nickname is registered by another person">>, ErrText = <<"That nickname is registered by another person">>,
Err = jlib:make_error_reply(Packet, Err = jlib:make_error_reply(Packet,
?ERRT_CONFLICT(Lang, ErrText)), ?ERRT_CONFLICT(Lang, ErrText)),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
Nick), Nick),
From, Err), From, Err),
StateData; StateData;
@ -1859,14 +1859,14 @@ add_new_user(From, Nick,
?ERRT_NOT_AUTHORIZED(Lang, ?ERRT_NOT_AUTHORIZED(Lang,
ErrText)), ErrText)),
ejabberd_router:route % TODO: s/Nick/""/ ejabberd_router:route % TODO: s/Nick/""/
(jlib:jid_replace_resource(StateData#state.jid, (jid:replace_resource(StateData#state.jid,
Nick), Nick),
From, Err), From, Err),
StateData; StateData;
captcha_required -> captcha_required ->
SID = xml:get_attr_s(<<"id">>, Attrs), SID = xml:get_attr_s(<<"id">>, Attrs),
RoomJID = StateData#state.jid, RoomJID = StateData#state.jid,
To = jlib:jid_replace_resource(RoomJID, Nick), To = jid:replace_resource(RoomJID, Nick),
Limiter = {From#jid.luser, From#jid.lserver}, Limiter = {From#jid.luser, From#jid.lserver},
case ejabberd_captcha:create_captcha(SID, RoomJID, To, case ejabberd_captcha:create_captcha(SID, RoomJID, To,
Lang, Limiter, From) Lang, Limiter, From)
@ -1885,7 +1885,7 @@ add_new_user(From, Nick,
?ERRT_RESOURCE_CONSTRAINT(Lang, ?ERRT_RESOURCE_CONSTRAINT(Lang,
ErrText)), ErrText)),
ejabberd_router:route % TODO: s/Nick/""/ ejabberd_router:route % TODO: s/Nick/""/
(jlib:jid_replace_resource(StateData#state.jid, (jid:replace_resource(StateData#state.jid,
Nick), Nick),
From, Err), From, Err),
StateData; StateData;
@ -1895,7 +1895,7 @@ add_new_user(From, Nick,
?ERRT_INTERNAL_SERVER_ERROR(Lang, ?ERRT_INTERNAL_SERVER_ERROR(Lang,
ErrText)), ErrText)),
ejabberd_router:route % TODO: s/Nick/""/ ejabberd_router:route % TODO: s/Nick/""/
(jlib:jid_replace_resource(StateData#state.jid, (jid:replace_resource(StateData#state.jid,
Nick), Nick),
From, Err), From, Err),
StateData StateData
@ -1906,7 +1906,7 @@ add_new_user(From, Nick,
?ERRT_NOT_AUTHORIZED(Lang, ?ERRT_NOT_AUTHORIZED(Lang,
ErrText)), ErrText)),
ejabberd_router:route % TODO: s/Nick/""/ ejabberd_router:route % TODO: s/Nick/""/
(jlib:jid_replace_resource(StateData#state.jid, (jid:replace_resource(StateData#state.jid,
Nick), Nick),
From, Err), From, Err),
StateData StateData
@ -2086,7 +2086,7 @@ send_update_presence(JID, Reason, StateData) ->
end. end.
send_update_presence1(JID, Reason, StateData) -> send_update_presence1(JID, Reason, StateData) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
LJIDs = case LJID of LJIDs = case LJID of
{U, S, <<"">>} -> {U, S, <<"">>} ->
(?DICT):fold(fun (J, _, Js) -> (?DICT):fold(fun (J, _, Js) ->
@ -2120,13 +2120,13 @@ send_new_presence(NJID, Reason, StateData, OldStateData) ->
send_new_presence1(NJID, Reason, StateData) -> send_new_presence1(NJID, Reason, StateData) ->
#user{nick = Nick} = #user{nick = Nick} =
(?DICT):fetch(jlib:jid_tolower(NJID), (?DICT):fetch(jid:tolower(NJID),
StateData#state.users), StateData#state.users),
LJID = find_jid_by_nick(Nick, StateData), LJID = find_jid_by_nick(Nick, StateData),
{ok, {ok,
#user{jid = RealJID, role = Role, #user{jid = RealJID, role = Role,
last_presence = Presence}} = last_presence = Presence}} =
(?DICT):find(jlib:jid_tolower(LJID), (?DICT):find(jid:tolower(LJID),
StateData#state.users), StateData#state.users),
Affiliation = get_affiliation(LJID, StateData), Affiliation = get_affiliation(LJID, StateData),
SAffiliation = affiliation_to_list(Affiliation), SAffiliation = affiliation_to_list(Affiliation),
@ -2138,7 +2138,7 @@ send_new_presence1(NJID, Reason, StateData) ->
of of
true -> true ->
[{<<"jid">>, [{<<"jid">>,
jlib:jid_to_string(RealJID)}, jid:to_string(RealJID)},
{<<"affiliation">>, SAffiliation}, {<<"affiliation">>, SAffiliation},
{<<"role">>, SRole}]; {<<"role">>, SRole}];
_ -> _ ->
@ -2198,7 +2198,7 @@ send_new_presence1(NJID, Reason, StateData) ->
= =
ItemEls} ItemEls}
| Status3]}]), | Status3]}]),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
Nick), Nick),
Info#user.jid, Packet) Info#user.jid, Packet)
end, end,
@ -2211,14 +2211,14 @@ send_existing_presences(ToJID, StateData) ->
end. end.
send_existing_presences1(ToJID, StateData) -> send_existing_presences1(ToJID, StateData) ->
LToJID = jlib:jid_tolower(ToJID), LToJID = jid:tolower(ToJID),
{ok, #user{jid = RealToJID, role = Role}} = {ok, #user{jid = RealToJID, role = Role}} =
(?DICT):find(LToJID, StateData#state.users), (?DICT):find(LToJID, StateData#state.users),
lists:foreach(fun ({FromNick, _Users}) -> lists:foreach(fun ({FromNick, _Users}) ->
LJID = find_jid_by_nick(FromNick, StateData), LJID = find_jid_by_nick(FromNick, StateData),
#user{jid = FromJID, role = FromRole, #user{jid = FromJID, role = FromRole,
last_presence = Presence} = last_presence = Presence} =
(?DICT):fetch(jlib:jid_tolower(LJID), (?DICT):fetch(jid:tolower(LJID),
StateData#state.users), StateData#state.users),
case RealToJID of case RealToJID of
FromJID -> ok; FromJID -> ok;
@ -2231,7 +2231,7 @@ send_existing_presences1(ToJID, StateData) ->
of of
true -> true ->
[{<<"jid">>, [{<<"jid">>,
jlib:jid_to_string(FromJID)}, jid:to_string(FromJID)},
{<<"affiliation">>, {<<"affiliation">>,
affiliation_to_list(FromAffiliation)}, affiliation_to_list(FromAffiliation)},
{<<"role">>, {<<"role">>,
@ -2258,7 +2258,7 @@ send_existing_presences1(ToJID, StateData) ->
children children
= =
[]}]}]), []}]}]),
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
FromNick), FromNick),
RealToJID, Packet) RealToJID, Packet)
end end
@ -2269,7 +2269,7 @@ now_to_usec({MSec, Sec, USec}) ->
(MSec * 1000000 + Sec) * 1000000 + USec. (MSec * 1000000 + Sec) * 1000000 + USec.
change_nick(JID, Nick, StateData) -> change_nick(JID, Nick, StateData) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
{ok, #user{nick = OldNick}} = (?DICT):find(LJID, {ok, #user{nick = OldNick}} = (?DICT):find(LJID,
StateData#state.users), StateData#state.users),
Users = (?DICT):update(LJID, Users = (?DICT):update(LJID,
@ -2311,7 +2311,7 @@ send_nick_changing(JID, OldNick, StateData,
{ok, {ok,
#user{jid = RealJID, nick = Nick, role = Role, #user{jid = RealJID, nick = Nick, role = Role,
last_presence = Presence}} = last_presence = Presence}} =
(?DICT):find(jlib:jid_tolower(JID), (?DICT):find(jid:tolower(JID),
StateData#state.users), StateData#state.users),
Affiliation = get_affiliation(JID, StateData), Affiliation = get_affiliation(JID, StateData),
SAffiliation = affiliation_to_list(Affiliation), SAffiliation = affiliation_to_list(Affiliation),
@ -2323,7 +2323,7 @@ send_nick_changing(JID, OldNick, StateData,
of of
true -> true ->
[{<<"jid">>, [{<<"jid">>,
jlib:jid_to_string(RealJID)}, jid:to_string(RealJID)},
{<<"affiliation">>, SAffiliation}, {<<"affiliation">>, SAffiliation},
{<<"role">>, SRole}, {<<"role">>, SRole},
{<<"nick">>, Nick}]; {<<"nick">>, Nick}];
@ -2338,7 +2338,7 @@ send_nick_changing(JID, OldNick, StateData,
of of
true -> true ->
[{<<"jid">>, [{<<"jid">>,
jlib:jid_to_string(RealJID)}, jid:to_string(RealJID)},
{<<"affiliation">>, SAffiliation}, {<<"affiliation">>, SAffiliation},
{<<"role">>, SRole}]; {<<"role">>, SRole}];
_ -> _ ->
@ -2392,13 +2392,13 @@ send_nick_changing(JID, OldNick, StateData,
= =
[]}|Status110]}]), []}|Status110]}]),
if SendOldUnavailable -> if SendOldUnavailable ->
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
OldNick), OldNick),
Info#user.jid, Packet1); Info#user.jid, Packet1);
true -> ok true -> ok
end, end,
if SendNewAvailable -> if SendNewAvailable ->
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
Nick), Nick),
Info#user.jid, Packet2); Info#user.jid, Packet2);
true -> ok true -> ok
@ -2442,7 +2442,7 @@ add_message_to_history(FromNick, FromJID, Packet, StateData) ->
Address = #xmlel{name = <<"address">>, Address = #xmlel{name = <<"address">>,
attrs = [{<<"type">>, <<"ofrom">>}, attrs = [{<<"type">>, <<"ofrom">>},
{<<"jid">>, {<<"jid">>,
jlib:jid_to_string(FromJID)}], jid:to_string(FromJID)}],
children = []}, children = []},
Addresses = #xmlel{name = <<"addresses">>, Addresses = #xmlel{name = <<"addresses">>,
attrs = [{<<"xmlns">>, ?NS_ADDRESS}], attrs = [{<<"xmlns">>, ?NS_ADDRESS}],
@ -2451,7 +2451,7 @@ add_message_to_history(FromNick, FromJID, Packet, StateData) ->
end, end,
TSPacket = jlib:add_delay_info(AddrPacket, StateData#state.jid, TimeStamp), TSPacket = jlib:add_delay_info(AddrPacket, StateData#state.jid, TimeStamp),
SPacket = SPacket =
jlib:replace_from_to(jlib:jid_replace_resource(StateData#state.jid, jlib:replace_from_to(jid:replace_resource(StateData#state.jid,
FromNick), FromNick),
StateData#state.jid, TSPacket), StateData#state.jid, TSPacket),
Size = element_size(SPacket), Size = element_size(SPacket),
@ -2465,7 +2465,7 @@ send_history(JID, Shift, StateData) ->
lists:foldl(fun ({Nick, Packet, HaveSubject, _TimeStamp, lists:foldl(fun ({Nick, Packet, HaveSubject, _TimeStamp,
_Size}, _Size},
B) -> B) ->
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
Nick), Nick),
JID, Packet), JID, Packet),
B or HaveSubject B or HaveSubject
@ -2556,7 +2556,7 @@ items_with_affiliation(SAffiliation, StateData) ->
attrs = attrs =
[{<<"affiliation">>, [{<<"affiliation">>,
affiliation_to_list(Affiliation)}, affiliation_to_list(Affiliation)},
{<<"jid">>, jlib:jid_to_string(JID)}], {<<"jid">>, jid:to_string(JID)}],
children = children =
[#xmlel{name = <<"reason">>, attrs = [], [#xmlel{name = <<"reason">>, attrs = [],
children = [{xmlcdata, Reason}]}]}; children = [{xmlcdata, Reason}]}]};
@ -2565,7 +2565,7 @@ items_with_affiliation(SAffiliation, StateData) ->
attrs = attrs =
[{<<"affiliation">>, [{<<"affiliation">>,
affiliation_to_list(Affiliation)}, affiliation_to_list(Affiliation)},
{<<"jid">>, jlib:jid_to_string(JID)}], {<<"jid">>, jid:to_string(JID)}],
children = []} children = []}
end, end,
search_affiliation(SAffiliation, StateData)). search_affiliation(SAffiliation, StateData)).
@ -2578,7 +2578,7 @@ user_to_item(#user{role = Role, nick = Nick, jid = JID},
[{<<"role">>, role_to_list(Role)}, [{<<"role">>, role_to_list(Role)},
{<<"affiliation">>, affiliation_to_list(Affiliation)}, {<<"affiliation">>, affiliation_to_list(Affiliation)},
{<<"nick">>, Nick}, {<<"nick">>, Nick},
{<<"jid">>, jlib:jid_to_string(JID)}], {<<"jid">>, jid:to_string(JID)}],
children = []}. children = []}.
search_role(Role, StateData) -> search_role(Role, StateData) ->
@ -2604,8 +2604,8 @@ process_admin_items_set(UJID, Items, Lang, StateData) ->
{result, Res} -> {result, Res} ->
?INFO_MSG("Processing MUC admin query from ~s in " ?INFO_MSG("Processing MUC admin query from ~s in "
"room ~s:~n ~p", "room ~s:~n ~p",
[jlib:jid_to_string(UJID), [jid:to_string(UJID),
jlib:jid_to_string(StateData#state.jid), Res]), jid:to_string(StateData#state.jid), Res]),
NSD = lists:foldl(process_item_change(UJID), NSD = lists:foldl(process_item_change(UJID),
StateData, lists:flatten(Res)), StateData, lists:flatten(Res)),
case (NSD#state.config)#config.persistent of case (NSD#state.config)#config.persistent of
@ -2705,7 +2705,7 @@ find_changed_items(UJID, UAffiliation, URole,
Lang, StateData, Res) -> Lang, StateData, Res) ->
TJID = case xml:get_attr(<<"jid">>, Attrs) of TJID = case xml:get_attr(<<"jid">>, Attrs) of
{value, S} -> {value, S} ->
case jlib:string_to_jid(S) of case jid:from_string(S) of
error -> error ->
ErrText = iolist_to_binary( ErrText = iolist_to_binary(
io_lib:format(translate:translate( io_lib:format(translate:translate(
@ -2766,9 +2766,9 @@ find_changed_items(UJID, UAffiliation, URole,
StateData) StateData)
of of
[{OJID, _}] -> [{OJID, _}] ->
jlib:jid_remove_resource(OJID) jid:remove_resource(OJID)
/= /=
jlib:jid_tolower(jlib:jid_remove_resource(UJID)); jid:tolower(jid:remove_resource(UJID));
_ -> true _ -> true
end; end;
_ -> false _ -> false
@ -2782,7 +2782,7 @@ find_changed_items(UJID, UAffiliation, URole,
Reason = xml:get_path_s(Item, Reason = xml:get_path_s(Item,
[{elem, <<"reason">>}, [{elem, <<"reason">>},
cdata]), cdata]),
MoreRes = [{jlib:jid_remove_resource(Jidx), MoreRes = [{jid:remove_resource(Jidx),
affiliation, SAffiliation, Reason} affiliation, SAffiliation, Reason}
|| Jidx <- JIDs], || Jidx <- JIDs],
find_changed_items(UJID, UAffiliation, URole, find_changed_items(UJID, UAffiliation, URole,
@ -2814,9 +2814,9 @@ find_changed_items(UJID, UAffiliation, URole,
StateData) StateData)
of of
[{OJID, _}] -> [{OJID, _}] ->
jlib:jid_remove_resource(OJID) jid:remove_resource(OJID)
/= /=
jlib:jid_tolower(jlib:jid_remove_resource(UJID)); jid:tolower(jid:remove_resource(UJID));
_ -> true _ -> true
end; end;
_ -> false _ -> false
@ -2975,7 +2975,7 @@ send_kickban_presence(UJID, JID, Reason, Code, StateData) ->
send_kickban_presence(UJID, JID, Reason, Code, NewAffiliation, send_kickban_presence(UJID, JID, Reason, Code, NewAffiliation,
StateData) -> StateData) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
LJIDs = case LJID of LJIDs = case LJID of
{U, S, <<"">>} -> {U, S, <<"">>} ->
(?DICT):fold(fun (J, _, Js) -> (?DICT):fold(fun (J, _, Js) ->
@ -3004,14 +3004,14 @@ send_kickban_presence(UJID, JID, Reason, Code, NewAffiliation,
send_kickban_presence1(MJID, UJID, Reason, Code, Affiliation, send_kickban_presence1(MJID, UJID, Reason, Code, Affiliation,
StateData) -> StateData) ->
{ok, #user{jid = RealJID, nick = Nick}} = {ok, #user{jid = RealJID, nick = Nick}} =
(?DICT):find(jlib:jid_tolower(UJID), (?DICT):find(jid:tolower(UJID),
StateData#state.users), StateData#state.users),
SAffiliation = affiliation_to_list(Affiliation), SAffiliation = affiliation_to_list(Affiliation),
BannedJIDString = jlib:jid_to_string(RealJID), BannedJIDString = jid:to_string(RealJID),
case MJID /= <<"">> of case MJID /= <<"">> of
true -> true ->
{ok, #user{nick = ActorNick}} = {ok, #user{nick = ActorNick}} =
(?DICT):find(jlib:jid_tolower(MJID), (?DICT):find(jid:tolower(MJID),
StateData#state.users); StateData#state.users);
false -> false ->
ActorNick = <<"">> ActorNick = <<"">>
@ -3064,7 +3064,7 @@ send_kickban_presence1(MJID, UJID, Reason, Code, Affiliation,
Code}], Code}],
children = children =
[]}]}]}, []}]}]},
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
Nick), Nick),
Info#user.jid, Packet) Info#user.jid, Packet)
end, end,
@ -3099,8 +3099,8 @@ process_iq_owner(From, set, Lang, SubEl, StateData) ->
end; end;
[#xmlel{name = <<"destroy">>} = SubEl1] -> [#xmlel{name = <<"destroy">>} = SubEl1] ->
?INFO_MSG("Destroyed MUC room ~s by the owner ~s", ?INFO_MSG("Destroyed MUC room ~s by the owner ~s",
[jlib:jid_to_string(StateData#state.jid), [jid:to_string(StateData#state.jid),
jlib:jid_to_string(From)]), jid:to_string(From)]),
add_to_log(room_existence, destroyed, StateData), add_to_log(room_existence, destroyed, StateData),
destroy_room(SubEl1, StateData); destroy_room(SubEl1, StateData);
Items -> Items ->
@ -3265,7 +3265,7 @@ is_password_settings_correct(XEl, StateData) ->
{<<"var">>, Var}], {<<"var">>, Var}],
children = children =
[#xmlel{name = <<"value">>, attrs = [], [#xmlel{name = <<"value">>, attrs = [],
children = [{xmlcdata, jlib:jid_to_string(JID)}]} children = [{xmlcdata, jid:to_string(JID)}]}
|| JID <- JIDList]}). || JID <- JIDList]}).
get_default_room_maxusers(RoomState) -> get_default_room_maxusers(RoomState) ->
@ -3301,7 +3301,7 @@ get_config(Lang, StateData, From) ->
translate:translate( translate:translate(
Lang, Lang,
<<"Configuration of room ~s">>), <<"Configuration of room ~s">>),
[jlib:jid_to_string(StateData#state.jid)]))}]}, [jid:to_string(StateData#state.jid)]))}]},
#xmlel{name = <<"field">>, #xmlel{name = <<"field">>,
attrs = attrs =
[{<<"type">>, <<"hidden">>}, [{<<"type">>, <<"hidden">>},
@ -3799,7 +3799,7 @@ set_xoption([{<<"muc#roomconfig_captcha_whitelist">>,
Vals} Vals}
| Opts], | Opts],
Config) -> Config) ->
JIDs = [jlib:string_to_jid(Val) || Val <- Vals], JIDs = [jid:from_string(Val) || Val <- Vals],
?SET_JIDMULTI_XOPT(captcha_whitelist, JIDs); ?SET_JIDMULTI_XOPT(captcha_whitelist, JIDs);
set_xoption([{<<"FORM_TYPE">>, _} | Opts], Config) -> set_xoption([{<<"FORM_TYPE">>, _} | Opts], Config) ->
set_xoption(Opts, Config); set_xoption(Opts, Config);
@ -4051,7 +4051,7 @@ destroy_room(DEl, StateData) ->
children = children =
[]}, []},
DEl]}]}, DEl]}]},
ejabberd_router:route(jlib:jid_replace_resource(StateData#state.jid, ejabberd_router:route(jid:replace_resource(StateData#state.jid,
Nick), Nick),
Info#user.jid, Packet) Info#user.jid, Packet)
end, end,
@ -4218,7 +4218,7 @@ get_mucroom_disco_items(StateData) ->
#xmlel{name = <<"item">>, #xmlel{name = <<"item">>,
attrs = attrs =
[{<<"jid">>, [{<<"jid">>,
jlib:jid_to_string({StateData#state.room, jid:to_string({StateData#state.room,
StateData#state.host, StateData#state.host,
Nick})}, Nick})},
{<<"name">>, Nick}], {<<"name">>, Nick}],
@ -4295,7 +4295,7 @@ prepare_request_form(Requester, Nick, Lang) ->
[{xmlcdata, [{xmlcdata,
<<"participant">>}]}]}, <<"participant">>}]}]},
?STRINGXFIELD(<<"User JID">>, <<"muc#jid">>, ?STRINGXFIELD(<<"User JID">>, <<"muc#jid">>,
(jlib:jid_to_string(Requester))), (jid:to_string(Requester))),
?STRINGXFIELD(<<"Nickname">>, <<"muc#roomnick">>, ?STRINGXFIELD(<<"Nickname">>, <<"muc#roomnick">>,
Nick), Nick),
?BOOLXFIELD(<<"Grant voice to this person?">>, ?BOOLXFIELD(<<"Grant voice to this person?">>,
@ -4352,7 +4352,7 @@ extract_jid_from_voice_approvement(Els) ->
Res -> Res Res -> Res
end, end,
lists:foldl(fun ({<<"muc#jid">>, [JIDStr]}, error) -> lists:foldl(fun ({<<"muc#jid">>, [JIDStr]}, error) ->
case jlib:string_to_jid(JIDStr) of case jid:from_string(JIDStr) of
error -> error; error -> error;
J -> {ok, J} J -> {ok, J}
end; end;
@ -4401,7 +4401,7 @@ check_invitation(From, Els, Lang, StateData) ->
_ -> throw({error, ?ERR_BAD_REQUEST}) _ -> throw({error, ?ERR_BAD_REQUEST})
end, end,
JID = case JID = case
jlib:string_to_jid(xml:get_tag_attr_s(<<"to">>, jid:from_string(xml:get_tag_attr_s(<<"to">>,
InviteEl)) InviteEl))
of of
error -> throw({error, ?ERR_JID_MALFORMED}); error -> throw({error, ?ERR_JID_MALFORMED});
@ -4419,7 +4419,7 @@ check_invitation(From, Els, Lang, StateData) ->
Continue1 -> [Continue1] Continue1 -> [Continue1]
end, end,
IEl = [#xmlel{name = <<"invite">>, IEl = [#xmlel{name = <<"invite">>,
attrs = [{<<"from">>, jlib:jid_to_string(From)}], attrs = [{<<"from">>, jid:to_string(From)}],
children = children =
[#xmlel{name = <<"reason">>, attrs = [], [#xmlel{name = <<"reason">>, attrs = [],
children = [{xmlcdata, Reason}]}] children = [{xmlcdata, Reason}]}]
@ -4442,8 +4442,8 @@ check_invitation(From, Els, Lang, StateData) ->
translate:translate( translate:translate(
Lang, Lang,
<<"~s invites you to the room ~s">>), <<"~s invites you to the room ~s">>),
[jlib:jid_to_string(From), [jid:to_string(From),
jlib:jid_to_string({StateData#state.room, jid:to_string({StateData#state.room,
StateData#state.host, StateData#state.host,
<<"">>})]), <<"">>})]),
case case
@ -4473,7 +4473,7 @@ check_invitation(From, Els, Lang, StateData) ->
attrs = attrs =
[{<<"xmlns">>, ?NS_XCONFERENCE}, [{<<"xmlns">>, ?NS_XCONFERENCE},
{<<"jid">>, {<<"jid">>,
jlib:jid_to_string({StateData#state.room, jid:to_string({StateData#state.room,
StateData#state.host, StateData#state.host,
<<"">>})}], <<"">>})}],
children = [{xmlcdata, Reason}]}, children = [{xmlcdata, Reason}]},
@ -4506,7 +4506,7 @@ check_decline_invitation(Packet) ->
(?NS_MUC_USER) = xml:get_tag_attr_s(<<"xmlns">>, XEl), (?NS_MUC_USER) = xml:get_tag_attr_s(<<"xmlns">>, XEl),
DEl = xml:get_subtag(XEl, <<"decline">>), DEl = xml:get_subtag(XEl, <<"decline">>),
ToString = xml:get_tag_attr_s(<<"to">>, DEl), ToString = xml:get_tag_attr_s(<<"to">>, DEl),
ToJID = jlib:string_to_jid(ToString), ToJID = jid:from_string(ToString),
{true, {Packet, XEl, DEl, ToJID}}. {true, {Packet, XEl, DEl, ToJID}}.
%% Send the decline to the inviter user. %% Send the decline to the inviter user.
@ -4514,7 +4514,7 @@ check_decline_invitation(Packet) ->
send_decline_invitation({Packet, XEl, DEl, ToJID}, send_decline_invitation({Packet, XEl, DEl, ToJID},
RoomJID, FromJID) -> RoomJID, FromJID) ->
FromString = FromString =
jlib:jid_to_string(jlib:jid_remove_resource(FromJID)), jid:to_string(jid:remove_resource(FromJID)),
#xmlel{name = <<"decline">>, attrs = DAttrs, #xmlel{name = <<"decline">>, attrs = DAttrs,
children = DEls} = children = DEls} =
DEl, DEl,
@ -4564,7 +4564,7 @@ add_to_log(Type, Data, StateData) ->
%% Users number checking %% Users number checking
tab_add_online_user(JID, StateData) -> tab_add_online_user(JID, StateData) ->
{LUser, LServer, LResource} = jlib:jid_tolower(JID), {LUser, LServer, LResource} = jid:tolower(JID),
US = {LUser, LServer}, US = {LUser, LServer},
Room = StateData#state.room, Room = StateData#state.room,
Host = StateData#state.host, Host = StateData#state.host,
@ -4573,7 +4573,7 @@ tab_add_online_user(JID, StateData) ->
room = Room, host = Host}). room = Room, host = Host}).
tab_remove_online_user(JID, StateData) -> tab_remove_online_user(JID, StateData) ->
{LUser, LServer, LResource} = jlib:jid_tolower(JID), {LUser, LServer, LResource} = jid:tolower(JID),
US = {LUser, LServer}, US = {LUser, LServer},
Room = StateData#state.room, Room = StateData#state.room,
Host = StateData#state.host, Host = StateData#state.host,
@ -4582,7 +4582,7 @@ tab_remove_online_user(JID, StateData) ->
room = Room, host = Host}). room = Room, host = Host}).
tab_count_user(JID) -> tab_count_user(JID) ->
{LUser, LServer, _} = jlib:jid_tolower(JID), {LUser, LServer, _} = jid:tolower(JID),
US = {LUser, LServer}, US = {LUser, LServer},
case catch ets:select(muc_online_users, case catch ets:select(muc_online_users,
[{#muc_online_users{us = US, _ = '_'}, [], [[]]}]) [{#muc_online_users{us = US, _ = '_'}, [], [[]]}])

View File

@ -871,7 +871,7 @@ process_discoitems_result(From, LServiceS, Els) ->
case XML of case XML of
#xmlel{name = <<"item">>, attrs = Attrs} -> #xmlel{name = <<"item">>, attrs = Attrs} ->
SJID = xml:get_attr_s(<<"jid">>, Attrs), SJID = xml:get_attr_s(<<"jid">>, Attrs),
case jlib:string_to_jid(SJID) of case jid:from_string(SJID) of
#jid{luser = <<"">>, #jid{luser = <<"">>,
lresource = <<"">>} -> lresource = <<"">>} ->
[SJID | Res]; [SJID | Res];
@ -1214,9 +1214,9 @@ make_reply(internal_server_error, Lang, ErrText) ->
make_reply(forbidden, Lang, ErrText) -> make_reply(forbidden, Lang, ErrText) ->
?ERRT_FORBIDDEN(Lang, ErrText). ?ERRT_FORBIDDEN(Lang, ErrText).
stj(String) -> jlib:string_to_jid(String). stj(String) -> jid:from_string(String).
jts(String) -> jlib:jid_to_string(String). jts(String) -> jid:to_string(String).
mod_opt_type(access) -> mod_opt_type(access) ->
fun (A) when is_atom(A) -> A end; fun (A) when is_atom(A) -> A end;

View File

@ -248,7 +248,7 @@ store_offline_msg(Host, {User, _}, Msgs, Len, MaxOfflineMsgs,
get_max_user_messages(AccessRule, {User, Server}, Host) -> get_max_user_messages(AccessRule, {User, Server}, Host) ->
case acl:match_rule( case acl:match_rule(
Host, AccessRule, jlib:make_jid(User, Server, <<"">>)) of Host, AccessRule, jid:make(User, Server, <<"">>)) of
Max when is_integer(Max) -> Max; Max when is_integer(Max) -> Max;
infinity -> infinity; infinity -> infinity;
_ -> ?MAX_USER_MESSAGES _ -> ?MAX_USER_MESSAGES
@ -400,8 +400,8 @@ find_x_expire(TimeStamp, [El | Els]) ->
end. end.
resend_offline_messages(User, Server) -> resend_offline_messages(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
F = fun () -> F = fun () ->
Rs = mnesia:wread({offline_msg, US}), Rs = mnesia:wread({offline_msg, US}),
@ -423,8 +423,8 @@ resend_offline_messages(User, Server) ->
end. end.
pop_offline_messages(Ls, User, Server) -> pop_offline_messages(Ls, User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
pop_offline_messages(Ls, LUser, LServer, pop_offline_messages(Ls, LUser, LServer,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -504,7 +504,7 @@ pop_offline_messages(Ls, LUser, LServer, riak) ->
end. end.
remove_expired_messages(Server) -> remove_expired_messages(Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
remove_expired_messages(LServer, remove_expired_messages(LServer,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -529,7 +529,7 @@ remove_expired_messages(_LServer, odbc) -> {atomic, ok};
remove_expired_messages(_LServer, riak) -> {atomic, ok}. remove_expired_messages(_LServer, riak) -> {atomic, ok}.
remove_old_messages(Days, Server) -> remove_old_messages(Days, Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
remove_old_messages(Days, LServer, remove_old_messages(Days, LServer,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -568,8 +568,8 @@ remove_old_messages(_Days, _LServer, riak) ->
{atomic, ok}. {atomic, ok}.
remove_user(User, Server) -> remove_user(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
remove_user(LUser, LServer, remove_user(LUser, LServer,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -678,8 +678,8 @@ offline_msg_to_route(LServer, #offline_msg{} = R) ->
jlib:add_delay_info(R#offline_msg.packet, LServer, R#offline_msg.timestamp, jlib:add_delay_info(R#offline_msg.packet, LServer, R#offline_msg.timestamp,
<<"Offline Storage">>)}; <<"Offline Storage">>)};
offline_msg_to_route(_LServer, #xmlel{} = El) -> offline_msg_to_route(_LServer, #xmlel{} = El) ->
To = jlib:string_to_jid(xml:get_tag_attr_s(<<"to">>, El)), To = jid:from_string(xml:get_tag_attr_s(<<"to">>, El)),
From = jlib:string_to_jid(xml:get_tag_attr_s(<<"from">>, El)), From = jid:from_string(xml:get_tag_attr_s(<<"from">>, El)),
if (To /= error) and (From /= error) -> if (To /= error) and (From /= error) ->
{route, From, To, El}; {route, From, To, El};
true -> true ->
@ -731,8 +731,8 @@ format_user_queue(Msgs, DBType) when DBType == mnesia; DBType == riak ->
[Year, Month, Day, [Year, Month, Day,
Hour, Minute, Hour, Minute,
Second])), Second])),
SFrom = jlib:jid_to_string(From), SFrom = jid:to_string(From),
STo = jlib:jid_to_string(To), STo = jid:to_string(To),
Attrs2 = jlib:replace_from_to_attrs(SFrom, STo, Attrs), Attrs2 = jlib:replace_from_to_attrs(SFrom, STo, Attrs),
Packet = #xmlel{name = Name, attrs = Attrs2, Packet = #xmlel{name = Name, attrs = Attrs2,
children = Els}, children = Els},
@ -761,8 +761,8 @@ format_user_queue(Msgs, odbc) ->
Msgs). Msgs).
user_queue(User, Server, Query, Lang) -> user_queue(User, Server, Query, Lang) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
DBType = gen_mod:db_type(LServer, ?MODULE), DBType = gen_mod:db_type(LServer, ?MODULE),
Res = user_queue_parse_query(LUser, LServer, Query, Res = user_queue_parse_query(LUser, LServer, Query,
@ -893,7 +893,7 @@ user_queue_parse_query(LUser, LServer, Query, odbc) ->
end. end.
us_to_list({User, Server}) -> us_to_list({User, Server}) ->
jlib:jid_to_string({User, Server, <<"">>}). jid:to_string({User, Server, <<"">>}).
get_queue_length(LUser, LServer) -> get_queue_length(LUser, LServer) ->
get_queue_length(LUser, LServer, get_queue_length(LUser, LServer,
@ -944,7 +944,7 @@ get_messages_subset2(Max, Length, MsgsAll, DBType)
{MsgsFirstN, Msgs2} = lists:split(FirstN, MsgsAll), {MsgsFirstN, Msgs2} = lists:split(FirstN, MsgsAll),
MsgsLastN = lists:nthtail(Length - FirstN - FirstN, MsgsLastN = lists:nthtail(Length - FirstN - FirstN,
Msgs2), Msgs2),
NoJID = jlib:make_jid(<<"...">>, <<"...">>, <<"">>), NoJID = jid:make(<<"...">>, <<"...">>, <<"">>),
IntermediateMsg = #offline_msg{timestamp = now(), IntermediateMsg = #offline_msg{timestamp = now(),
from = NoJID, to = NoJID, from = NoJID, to = NoJID,
packet = packet =
@ -961,8 +961,8 @@ get_messages_subset2(Max, Length, MsgsAll, odbc) ->
MsgsFirstN ++ [IntermediateMsg] ++ MsgsLastN. MsgsFirstN ++ [IntermediateMsg] ++ MsgsLastN.
webadmin_user(Acc, User, Server, Lang) -> webadmin_user(Acc, User, Server, Lang) ->
QueueLen = get_queue_length(jlib:nodeprep(User), QueueLen = get_queue_length(jid:nodeprep(User),
jlib:nameprep(Server)), jid:nameprep(Server)),
FQueueLen = [?AC(<<"queue/">>, FQueueLen = [?AC(<<"queue/">>,
(iolist_to_binary(integer_to_list(QueueLen))))], (iolist_to_binary(integer_to_list(QueueLen))))],
Acc ++ Acc ++
@ -973,8 +973,8 @@ webadmin_user(Acc, User, Server, Lang) ->
<<"Remove All Offline Messages">>)]. <<"Remove All Offline Messages">>)].
delete_all_msgs(User, Server) -> delete_all_msgs(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
delete_all_msgs(LUser, LServer, delete_all_msgs(LUser, LServer,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -1014,8 +1014,8 @@ webadmin_user_parse_query(Acc, _Action, _User, _Server,
%% Returns as integer the number of offline messages for a given user %% Returns as integer the number of offline messages for a given user
count_offline_messages(User, Server) -> count_offline_messages(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
DBType = gen_mod:db_type(LServer, ?MODULE), DBType = gen_mod:db_type(LServer, ?MODULE),
count_offline_messages(LUser, LServer, DBType). count_offline_messages(LUser, LServer, DBType).
@ -1099,9 +1099,9 @@ import(LServer) ->
[{<<"select username, xml from spool;">>, [{<<"select username, xml from spool;">>,
fun([LUser, XML]) -> fun([LUser, XML]) ->
El = #xmlel{} = xml_stream:parse_element(XML), El = #xmlel{} = xml_stream:parse_element(XML),
From = #jid{} = jlib:string_to_jid( From = #jid{} = jid:from_string(
xml:get_attr_s(<<"from">>, El#xmlel.attrs)), xml:get_attr_s(<<"from">>, El#xmlel.attrs)),
To = #jid{} = jlib:string_to_jid( To = #jid{} = jid:from_string(
xml:get_attr_s(<<"to">>, El#xmlel.attrs)), xml:get_attr_s(<<"to">>, El#xmlel.attrs)),
Stamp = xml:get_path_s(El, [{elem, <<"delay">>}, Stamp = xml:get_path_s(El, [{elem, <<"delay">>},
{attr, <<"stamp">>}]), {attr, <<"stamp">>}]),

View File

@ -191,7 +191,7 @@ handle_info({timeout, _TRef, {ping, JID}}, State) ->
F = fun (Response) -> F = fun (Response) ->
gen_server:cast(Pid, {iq_pong, JID, Response}) gen_server:cast(Pid, {iq_pong, JID, Response})
end, end,
From = jlib:make_jid(<<"">>, State#state.host, <<"">>), From = jid:make(<<"">>, State#state.host, <<"">>),
ejabberd_local:route_iq(From, JID, IQ, F, State#state.ping_ack_timeout), ejabberd_local:route_iq(From, JID, IQ, F, State#state.ping_ack_timeout),
Timers = add_timer(JID, State#state.ping_interval, Timers = add_timer(JID, State#state.ping_interval,
State#state.timers), State#state.timers),
@ -227,7 +227,7 @@ user_send(Packet, _C2SState, JID, _From) ->
%% Internal functions %% Internal functions
%%==================================================================== %%====================================================================
add_timer(JID, Interval, Timers) -> add_timer(JID, Interval, Timers) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
NewTimers = case (?DICT):find(LJID, Timers) of NewTimers = case (?DICT):find(LJID, Timers) of
{ok, OldTRef} -> {ok, OldTRef} ->
cancel_timer(OldTRef), (?DICT):erase(LJID, Timers); cancel_timer(OldTRef), (?DICT):erase(LJID, Timers);
@ -238,7 +238,7 @@ add_timer(JID, Interval, Timers) ->
(?DICT):store(LJID, TRef, NewTimers). (?DICT):store(LJID, TRef, NewTimers).
del_timer(JID, Timers) -> del_timer(JID, Timers) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
case (?DICT):find(LJID, Timers) of case (?DICT):find(LJID, Timers) of
{ok, TRef} -> {ok, TRef} ->
cancel_timer(TRef), (?DICT):erase(LJID, Timers); cancel_timer(TRef), (?DICT):erase(LJID, Timers);

View File

@ -99,14 +99,14 @@ update(Server, JID, Dir) ->
in -> in ->
?WARNING_MSG("User ~s is being flooded, ignoring received " ?WARNING_MSG("User ~s is being flooded, ignoring received "
"presence subscriptions", "presence subscriptions",
[jlib:jid_to_string(JID)]); [jid:to_string(JID)]);
out -> out ->
IP = ejabberd_sm:get_user_ip(JID#jid.luser, IP = ejabberd_sm:get_user_ip(JID#jid.luser,
JID#jid.lserver, JID#jid.lserver,
JID#jid.lresource), JID#jid.lresource),
?WARNING_MSG("Flooder detected: ~s, on IP: ~s ignoring " ?WARNING_MSG("Flooder detected: ~s, on IP: ~s ignoring "
"sent presence subscriptions~n", "sent presence subscriptions~n",
[jlib:jid_to_string(JID), [jid:to_string(JID),
jlib:ip_to_list(IP)]) jlib:ip_to_list(IP)])
end, end,
{stop, deny}; {stop, deny};

View File

@ -322,7 +322,7 @@ type_to_list(Type) ->
value_to_list(Type, Val) -> value_to_list(Type, Val) ->
case Type of case Type of
jid -> jlib:jid_to_string(Val); jid -> jid:to_string(Val);
group -> Val; group -> Val;
subscription -> subscription ->
case Val of case Val of
@ -581,9 +581,9 @@ process_list_set(LUser, LServer, {value, Name}, Els) ->
of of
{atomic, conflict} -> {error, ?ERR_CONFLICT}; {atomic, conflict} -> {error, ?ERR_CONFLICT};
{atomic, ok} -> {atomic, ok} ->
ejabberd_sm:route(jlib:make_jid(LUser, LServer, ejabberd_sm:route(jid:make(LUser, LServer,
<<"">>), <<"">>),
jlib:make_jid(LUser, LServer, <<"">>), jid:make(LUser, LServer, <<"">>),
{broadcast, {privacy_list, {broadcast, {privacy_list,
#userlist{name = Name, #userlist{name = Name,
list = []}, list = []},
@ -597,9 +597,9 @@ process_list_set(LUser, LServer, {value, Name}, Els) ->
of of
{atomic, ok} -> {atomic, ok} ->
NeedDb = is_list_needdb(List), NeedDb = is_list_needdb(List),
ejabberd_sm:route(jlib:make_jid(LUser, LServer, ejabberd_sm:route(jid:make(LUser, LServer,
<<"">>), <<"">>),
jlib:make_jid(LUser, LServer, <<"">>), jid:make(LUser, LServer, <<"">>),
{broadcast, {privacy_list, {broadcast, {privacy_list,
#userlist{name = Name, #userlist{name = Name,
list = List, list = List,
@ -645,11 +645,11 @@ parse_items([#xmlel{name = <<"item">>, attrs = Attrs,
{{value, T}, {value, V}} -> {{value, T}, {value, V}} ->
case T of case T of
<<"jid">> -> <<"jid">> ->
case jlib:string_to_jid(V) of case jid:from_string(V) of
error -> false; error -> false;
JID -> JID ->
I1#listitem{type = jid, I1#listitem{type = jid,
value = jlib:jid_tolower(JID)} value = jid:tolower(JID)}
end; end;
<<"group">> -> I1#listitem{type = group, value = V}; <<"group">> -> I1#listitem{type = group, value = V};
<<"subscription">> -> <<"subscription">> ->
@ -715,8 +715,8 @@ is_list_needdb(Items) ->
Items). Items).
get_user_list(Acc, User, Server) -> get_user_list(Acc, User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
{Default, Items} = get_user_list(Acc, LUser, LServer, {Default, Items} = get_user_list(Acc, LUser, LServer,
gen_mod:db_type(LServer, ?MODULE)), gen_mod:db_type(LServer, ?MODULE)),
NeedDb = is_list_needdb(Items), NeedDb = is_list_needdb(Items),
@ -772,8 +772,8 @@ get_user_list(_, LUser, LServer, odbc) ->
end. end.
get_user_lists(User, Server) -> get_user_lists(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
get_user_lists(LUser, LServer, gen_mod:db_type(LServer, ?MODULE)). get_user_lists(LUser, LServer, gen_mod:db_type(LServer, ?MODULE)).
get_user_lists(LUser, LServer, mnesia) -> get_user_lists(LUser, LServer, mnesia) ->
@ -869,13 +869,13 @@ check_packet(_, User, Server,
{_, _} -> other {_, _} -> other
end, end,
LJID = case Dir of LJID = case Dir of
in -> jlib:jid_tolower(From); in -> jid:tolower(From);
out -> jlib:jid_tolower(To) out -> jid:tolower(To)
end, end,
{Subscription, Groups} = case NeedDb of {Subscription, Groups} = case NeedDb of
true -> true ->
ejabberd_hooks:run_fold(roster_get_jid_info, ejabberd_hooks:run_fold(roster_get_jid_info,
jlib:nameprep(Server), jid:nameprep(Server),
{none, []}, {none, []},
[User, Server, [User, Server,
LJID]); LJID]);
@ -944,8 +944,8 @@ is_type_match(Type, Value, JID, Subscription, Groups) ->
end. end.
remove_user(User, Server) -> remove_user(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
remove_user(LUser, LServer, remove_user(LUser, LServer,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -971,9 +971,9 @@ raw_to_item([SType, SValue, SAction, SOrder, SMatchAll,
{Type, Value} = case SType of {Type, Value} = case SType of
<<"n">> -> {none, none}; <<"n">> -> {none, none};
<<"j">> -> <<"j">> ->
case jlib:string_to_jid(SValue) of case jid:from_string(SValue) of
#jid{} = JID -> #jid{} = JID ->
{jid, jlib:jid_tolower(JID)} {jid, jid:tolower(JID)}
end; end;
<<"g">> -> {group, SValue}; <<"g">> -> {group, SValue};
<<"s">> -> <<"s">> ->
@ -1013,7 +1013,7 @@ item_to_raw(#listitem{type = Type, value = Value,
none -> {<<"n">>, <<"">>}; none -> {<<"n">>, <<"">>};
jid -> jid ->
{<<"j">>, {<<"j">>,
ejabberd_odbc:escape(jlib:jid_to_string(Value))}; ejabberd_odbc:escape(jid:to_string(Value))};
group -> {<<"g">>, ejabberd_odbc:escape(Value)}; group -> {<<"g">>, ejabberd_odbc:escape(Value)};
subscription -> subscription ->
case Value of case Value of
@ -1164,7 +1164,7 @@ update_table() ->
end. end.
export(Server) -> export(Server) ->
case catch ejabberd_odbc:sql_query(jlib:nameprep(Server), case catch ejabberd_odbc:sql_query(jid:nameprep(Server),
[<<"select id from privacy_list order by " [<<"select id from privacy_list order by "
"id desc limit 1;">>]) of "id desc limit 1;">>]) of
{selected, [<<"id">>], [[I]]} -> {selected, [<<"id">>], [[I]]} ->

View File

@ -243,8 +243,8 @@ private_storage_schema() ->
{record_info(fields, private_storage), #private_storage{}}. {record_info(fields, private_storage), #private_storage{}}.
remove_user(User, Server) -> remove_user(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
remove_user(LUser, LServer, remove_user(LUser, LServer,
gen_mod:db_type(Server, ?MODULE)). gen_mod:db_type(Server, ?MODULE)).

View File

@ -179,15 +179,15 @@ process_iq(InitiatorJID,
[{elem, <<"activate">>}]), [{elem, <<"activate">>}]),
SID = xml:get_tag_attr_s(<<"sid">>, SubEl), SID = xml:get_tag_attr_s(<<"sid">>, SubEl),
case catch case catch
jlib:string_to_jid(xml:get_tag_cdata(ActivateEl)) jid:from_string(xml:get_tag_cdata(ActivateEl))
of of
TargetJID TargetJID
when is_record(TargetJID, jid), SID /= <<"">>, when is_record(TargetJID, jid), SID /= <<"">>,
byte_size(SID) =< 128, TargetJID /= InitiatorJID -> byte_size(SID) =< 128, TargetJID /= InitiatorJID ->
Target = Target =
jlib:jid_to_string(jlib:jid_tolower(TargetJID)), jid:to_string(jid:tolower(TargetJID)),
Initiator = Initiator =
jlib:jid_to_string(jlib:jid_tolower(InitiatorJID)), jid:to_string(jid:tolower(InitiatorJID)),
SHA1 = p1_sha:sha(<<SID/binary, Initiator/binary, Target/binary>>), SHA1 = p1_sha:sha(<<SID/binary, Initiator/binary, Target/binary>>),
case mod_proxy65_sm:activate_stream(SHA1, InitiatorJID, case mod_proxy65_sm:activate_stream(SHA1, InitiatorJID,
TargetJID, ServerHost) TargetJID, ServerHost)

View File

@ -120,8 +120,8 @@ activate({P1, J1}, {P2, J2}) ->
{S1, S2} when is_port(S1), is_port(S2) -> {S1, S2} when is_port(S1), is_port(S2) ->
P1 ! {activate, P2, S2, J1, J2}, P1 ! {activate, P2, S2, J1, J2},
P2 ! {activate, P1, S1, J1, J2}, P2 ! {activate, P1, S1, J1, J2},
JID1 = jlib:jid_to_string(J1), JID1 = jid:to_string(J1),
JID2 = jlib:jid_to_string(J2), JID2 = jid:to_string(J2),
?INFO_MSG("(~w:~w) Activated bytestream for ~s " ?INFO_MSG("(~w:~w) Activated bytestream for ~s "
"-> ~s", "-> ~s",
[P1, P2, JID1, JID2]), [P1, P2, JID1, JID2]),

View File

@ -393,8 +393,8 @@ send_loop(State) ->
Host = State#state.host, Host = State#state.host,
ServerHost = State#state.server_host, ServerHost = State#state.server_host,
DBType = State#state.db_type, DBType = State#state.db_type,
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
BJID = jlib:jid_remove_resource(LJID), BJID = jid:remove_resource(LJID),
lists:foreach( lists:foreach(
fun(PType) -> fun(PType) ->
Subs = get_subscriptions_for_send_last(Host, PType, DBType, JID, LJID, BJID), Subs = get_subscriptions_for_send_last(Host, PType, DBType, JID, LJID, BJID),
@ -416,7 +416,7 @@ send_loop(State) ->
fun({U, S, R}) when S == ServerHost -> fun({U, S, R}) when S == ServerHost ->
case user_resources(U, S) of case user_resources(U, S) of
[] -> %% offline [] -> %% offline
PeerJID = jlib:make_jid(U, S, R), PeerJID = jid:make(U, S, R),
self() ! {presence, User, Server, [Resource], PeerJID}; self() ! {presence, User, Server, [Resource], PeerJID};
_ -> %% online _ -> %% online
% this is already handled by presence probe % this is already handled by presence probe
@ -437,7 +437,7 @@ send_loop(State) ->
{presence, User, Server, Resources, JID} -> {presence, User, Server, Resources, JID} ->
spawn(fun() -> spawn(fun() ->
Host = State#state.host, Host = State#state.host,
Owner = jlib:jid_remove_resource(jlib:jid_tolower(JID)), Owner = jid:remove_resource(jid:tolower(JID)),
lists:foreach(fun(#pubsub_node{nodeid = {_, Node}, type = Type, id = Nidx, options = Options}) -> lists:foreach(fun(#pubsub_node{nodeid = {_, Node}, type = Type, id = Nidx, options = Options}) ->
case match_option(Options, send_last_published_item, on_sub_and_presence) of case match_option(Options, send_last_published_item, on_sub_and_presence) of
true -> true ->
@ -533,7 +533,7 @@ disco_local_items(Acc, _From, _To, _Node, _Lang) -> Acc.
disco_sm_identity(empty, From, To, Node, Lang) -> disco_sm_identity(empty, From, To, Node, Lang) ->
disco_sm_identity([], From, To, Node, Lang); disco_sm_identity([], From, To, Node, Lang);
disco_sm_identity(Acc, From, To, Node, _Lang) -> disco_sm_identity(Acc, From, To, Node, _Lang) ->
disco_identity(jlib:jid_tolower(jlib:jid_remove_resource(To)), Node, From) disco_identity(jid:tolower(jid:remove_resource(To)), Node, From)
++ Acc. ++ Acc.
disco_identity(_Host, <<>>, _From) -> disco_identity(_Host, <<>>, _From) ->
@ -582,7 +582,7 @@ disco_sm_features(empty, From, To, Node, Lang) ->
disco_sm_features({result, OtherFeatures} = _Acc, From, To, Node, _Lang) -> disco_sm_features({result, OtherFeatures} = _Acc, From, To, Node, _Lang) ->
{result, {result,
OtherFeatures ++ OtherFeatures ++
disco_features(jlib:jid_tolower(jlib:jid_remove_resource(To)), Node, From)}; disco_features(jid:tolower(jid:remove_resource(To)), Node, From)};
disco_sm_features(Acc, _From, _To, _Node, _Lang) -> Acc. disco_sm_features(Acc, _From, _To, _Node, _Lang) -> Acc.
disco_features(Host, <<>>, _From) -> disco_features(Host, <<>>, _From) ->
@ -617,7 +617,7 @@ disco_sm_items(empty, From, To, Node, Lang) ->
disco_sm_items({result, []}, From, To, Node, Lang); disco_sm_items({result, []}, From, To, Node, Lang);
disco_sm_items({result, OtherItems}, From, To, Node, _Lang) -> disco_sm_items({result, OtherItems}, From, To, Node, _Lang) ->
{result, lists:usort(OtherItems ++ {result, lists:usort(OtherItems ++
disco_items(jlib:jid_tolower(jlib:jid_remove_resource(To)), Node, From))}; disco_items(jid:tolower(jid:remove_resource(To)), Node, From))};
disco_sm_items(Acc, _From, _To, _Node, _Lang) -> Acc. disco_sm_items(Acc, _From, _To, _Node, _Lang) -> Acc.
-spec(disco_items/3 :: -spec(disco_items/3 ::
@ -636,7 +636,7 @@ disco_items(Host, <<>>, From) ->
{result, _} -> {result, _} ->
[#xmlel{name = <<"item">>, [#xmlel{name = <<"item">>,
attrs = [{<<"node">>, (Node)}, attrs = [{<<"node">>, (Node)},
{<<"jid">>, jlib:jid_to_string(Host)} {<<"jid">>, jid:to_string(Host)}
| case get_option(Options, title) of | case get_option(Options, title) of
false -> []; false -> [];
[Title] -> [{<<"name">>, Title}] [Title] -> [{<<"name">>, Title}]
@ -660,7 +660,7 @@ disco_items(Host, Node, From) ->
case get_allowed_items_call(Host, Nidx, From, Type, Options, Owners) of case get_allowed_items_call(Host, Nidx, From, Type, Options, Owners) of
{result, Items} -> {result, Items} ->
{result, [#xmlel{name = <<"item">>, {result, [#xmlel{name = <<"item">>,
attrs = [{<<"jid">>, jlib:jid_to_string(Host)}, attrs = [{<<"jid">>, jid:to_string(Host)},
{<<"name">>, ItemId}]} {<<"name">>, ItemId}]}
|| #pubsub_item{itemid = {ItemId, _}} <- Items]}; || #pubsub_item{itemid = {ItemId, _}} <- Items]};
_ -> _ ->
@ -720,8 +720,8 @@ presence(ServerHost, Presence) ->
%% %%
out_subscription(User, Server, JID, subscribed) -> out_subscription(User, Server, JID, subscribed) ->
Owner = jlib:make_jid(User, Server, <<>>), Owner = jid:make(User, Server, <<>>),
{PUser, PServer, PResource} = jlib:jid_tolower(JID), {PUser, PServer, PResource} = jid:tolower(JID),
PResources = case PResource of PResources = case PResource of
<<>> -> user_resources(PUser, PServer); <<>> -> user_resources(PUser, PServer);
_ -> [PResource] _ -> [PResource]
@ -732,7 +732,7 @@ out_subscription(_, _, _, _) ->
true. true.
in_subscription(_, User, Server, Owner, unsubscribed, _) -> in_subscription(_, User, Server, Owner, unsubscribed, _) ->
unsubscribe_user(jlib:make_jid(User, Server, <<>>), Owner), unsubscribe_user(jid:make(User, Server, <<>>), Owner),
true; true;
in_subscription(_, _, _, _, _, _) -> in_subscription(_, _, _, _, _, _) ->
true. true.
@ -749,7 +749,7 @@ unsubscribe_user(Entity, Owner) ->
end, [], [Entity#jid.lserver, Owner#jid.lserver]))] end, [], [Entity#jid.lserver, Owner#jid.lserver]))]
end). end).
unsubscribe_user(Host, Entity, Owner) -> unsubscribe_user(Host, Entity, Owner) ->
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), BJID = jid:tolower(jid:remove_resource(Owner)),
lists:foreach(fun (PType) -> lists:foreach(fun (PType) ->
{result, Subs} = node_action(Host, PType, {result, Subs} = node_action(Host, PType,
get_entity_subscriptions, get_entity_subscriptions,
@ -780,9 +780,9 @@ unsubscribe_user(Host, Entity, Owner) ->
%% %%
remove_user(User, Server) -> remove_user(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
Entity = jlib:make_jid(LUser, LServer, <<>>), Entity = jid:make(LUser, LServer, <<>>),
Host = host(LServer), Host = host(LServer),
HomeTreeBase = <<"/home/", LServer/binary, "/", LUser/binary>>, HomeTreeBase = <<"/home/", LServer/binary, "/", LUser/binary>>,
spawn(fun () -> spawn(fun () ->
@ -1201,7 +1201,7 @@ iq_disco_items(Host, Item, From, RSM) ->
). ).
iq_sm(From, To, #iq{type = Type, sub_el = SubEl, xmlns = XMLNS, lang = Lang} = IQ) -> iq_sm(From, To, #iq{type = Type, sub_el = SubEl, xmlns = XMLNS, lang = Lang} = IQ) ->
ServerHost = To#jid.lserver, ServerHost = To#jid.lserver,
LOwner = jlib:jid_tolower(jlib:jid_remove_resource(To)), LOwner = jid:tolower(jid:remove_resource(To)),
Res = case XMLNS of Res = case XMLNS of
?NS_PUBSUB -> ?NS_PUBSUB ->
iq_pubsub(LOwner, ServerHost, From, Type, SubEl, Lang); iq_pubsub(LOwner, ServerHost, From, Type, SubEl, Lang);
@ -1495,7 +1495,7 @@ get_pending_nodes(Host, Owner, Plugins) ->
%% subscriptions on Host and Node.</p> %% subscriptions on Host and Node.</p>
send_pending_auth_events(Host, Node, Owner) -> send_pending_auth_events(Host, Node, Owner) ->
?DEBUG("Sending pending auth events for ~s on ~s:~s", ?DEBUG("Sending pending auth events for ~s on ~s:~s",
[jlib:jid_to_string(Owner), Host, Node]), [jid:to_string(Owner), Host, Node]),
Action = fun (#pubsub_node{id = Nidx, type = Type}) -> Action = fun (#pubsub_node{id = Nidx, type = Type}) ->
case lists:member(<<"get-pending">>, plugin_features(Host, Type)) of case lists:member(<<"get-pending">>, plugin_features(Host, Type)) of
true -> true ->
@ -1510,8 +1510,8 @@ send_pending_auth_events(Host, Node, Owner) ->
case transaction(Host, Node, Action, sync_dirty) of case transaction(Host, Node, Action, sync_dirty) of
{result, {N, Subs}} -> {result, {N, Subs}} ->
lists:foreach(fun lists:foreach(fun
({J, pending, _SubId}) -> send_authorization_request(N, jlib:make_jid(J)); ({J, pending, _SubId}) -> send_authorization_request(N, jid:make(J));
({J, pending}) -> send_authorization_request(N, jlib:make_jid(J)); ({J, pending}) -> send_authorization_request(N, jid:make(J));
(_) -> ok (_) -> ok
end, end,
Subs), Subs),
@ -1574,7 +1574,7 @@ send_authorization_request(#pubsub_node{nodeid = {Host, Node}, type = Type, id =
[#xmlel{name = <<"value">>, [#xmlel{name = <<"value">>,
attrs = [], attrs = [],
children = children =
[{xmlcdata, jlib:jid_to_string(Subscriber)}]}]}, [{xmlcdata, jid:to_string(Subscriber)}]}]},
#xmlel{name = <<"field">>, #xmlel{name = <<"field">>,
attrs = attrs =
[{<<"var">>, [{<<"var">>,
@ -1590,7 +1590,7 @@ send_authorization_request(#pubsub_node{nodeid = {Host, Node}, type = Type, id =
children = children =
[{xmlcdata, <<"false">>}]}]}]}]}, [{xmlcdata, <<"false">>}]}]}]}]},
lists:foreach(fun (Owner) -> lists:foreach(fun (Owner) ->
ejabberd_router:route(service_jid(Host), jlib:make_jid(Owner), Stanza) ejabberd_router:route(service_jid(Host), jid:make(Owner), Stanza)
end, end,
node_owners_action(Host, Type, Nidx, O)). node_owners_action(Host, Type, Nidx, O)).
@ -1635,7 +1635,7 @@ send_authorization_approval(Host, JID, SNode, Subscription) ->
[{<<"subscription">>, subscription_to_string(S)}] [{<<"subscription">>, subscription_to_string(S)}]
end, end,
Stanza = event_stanza(<<"subscription">>, Stanza = event_stanza(<<"subscription">>,
[{<<"jid">>, jlib:jid_to_string(JID)} [{<<"jid">>, jid:to_string(JID)}
| nodeAttr(SNode)] | nodeAttr(SNode)]
++ SubAttrs), ++ SubAttrs),
ejabberd_router:route(service_jid(Host), JID, Stanza). ejabberd_router:route(service_jid(Host), JID, Stanza).
@ -1648,8 +1648,8 @@ handle_authorization_response(Host, From, To, Packet, XFields) ->
{{value, {_, [Node]}}, {{value, {_, [Node]}},
{value, {_, [SSubscriber]}}, {value, {_, [SSubscriber]}},
{value, {_, [SAllow]}}} -> {value, {_, [SAllow]}}} ->
FromLJID = jlib:jid_tolower(jlib:jid_remove_resource(From)), FromLJID = jid:tolower(jid:remove_resource(From)),
Subscriber = jlib:string_to_jid(SSubscriber), Subscriber = jid:from_string(SSubscriber),
Allow = case SAllow of Allow = case SAllow of
<<"1">> -> true; <<"1">> -> true;
<<"true">> -> true; <<"true">> -> true;
@ -2045,7 +2045,7 @@ subscribe_node(Host, Node, From, JID, Configuration) ->
[#xmlel{name = <<"pubsub">>, [#xmlel{name = <<"pubsub">>,
attrs = [{<<"xmlns">>, ?NS_PUBSUB}], attrs = [{<<"xmlns">>, ?NS_PUBSUB}],
children = [#xmlel{name = <<"subscription">>, children = [#xmlel{name = <<"subscription">>,
attrs = [{<<"jid">>, jlib:jid_to_string(Subscriber)} attrs = [{<<"jid">>, jid:to_string(Subscriber)}
| SubAttrs]}]}] | SubAttrs]}]}]
end, end,
case transaction(Host, Node, Action, sync_dirty) of case transaction(Host, Node, Action, sync_dirty) of
@ -2526,13 +2526,13 @@ dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, Node,
Message = add_message_type(Stanza, NotificationType), Message = add_message_type(Stanza, NotificationType),
ejabberd_c2s:send_filtered(C2SPid, ejabberd_c2s:send_filtered(C2SPid,
{pep_message, <<Node/binary, "+notify">>}, {pep_message, <<Node/binary, "+notify">>},
service_jid(From), jlib:make_jid(To), service_jid(From), jid:make(To),
Message) Message)
end; end;
dispatch_items(From, To, _Node, Options, Stanza) -> dispatch_items(From, To, _Node, Options, Stanza) ->
NotificationType = get_option(Options, notification_type, headline), NotificationType = get_option(Options, notification_type, headline),
Message = add_message_type(Stanza, NotificationType), Message = add_message_type(Stanza, NotificationType),
ejabberd_router:route(service_jid(From), jlib:make_jid(To), Message). ejabberd_router:route(service_jid(From), jid:make(To), Message).
%% @doc <p>Return the list of affiliations as an XMPP response.</p> %% @doc <p>Return the list of affiliations as an XMPP response.</p>
-spec(get_affiliations/4 :: -spec(get_affiliations/4 ::
@ -2620,7 +2620,7 @@ get_affiliations(Host, Node, JID) ->
[]; [];
({AJID, Aff}) -> ({AJID, Aff}) ->
[#xmlel{name = <<"affiliation">>, [#xmlel{name = <<"affiliation">>,
attrs = [{<<"jid">>, jlib:jid_to_string(AJID)}, attrs = [{<<"jid">>, jid:to_string(AJID)},
{<<"affiliation">>, affiliation_to_string(Aff)}]}] {<<"affiliation">>, affiliation_to_string(Aff)}]}]
end, end,
Affs), Affs),
@ -2644,17 +2644,17 @@ get_affiliations(Host, Node, JID) ->
| {error, xmlel()} | {error, xmlel()}
). ).
set_affiliations(Host, Node, From, EntitiesEls) -> set_affiliations(Host, Node, From, EntitiesEls) ->
Owner = jlib:jid_tolower(jlib:jid_remove_resource(From)), Owner = jid:tolower(jid:remove_resource(From)),
Entities = lists:foldl(fun Entities = lists:foldl(fun
(_, error) -> (_, error) ->
error; error;
(El, Acc) -> (El, Acc) ->
case El of case El of
#xmlel{name = <<"affiliation">>, attrs = Attrs} -> #xmlel{name = <<"affiliation">>, attrs = Attrs} ->
JID = jlib:string_to_jid(xml:get_attr_s(<<"jid">>, Attrs)), JID = jid:from_string(xml:get_attr_s(<<"jid">>, Attrs)),
Affiliation = string_to_affiliation(xml:get_attr_s(<<"affiliation">>, Attrs)), Affiliation = string_to_affiliation(xml:get_attr_s(<<"affiliation">>, Attrs)),
if (JID == error) or (Affiliation == false) -> error; if (JID == error) or (Affiliation == false) -> error;
true -> [{jlib:jid_tolower(JID), Affiliation} | Acc] true -> [{jid:tolower(JID), Affiliation} | Acc]
end end
end end
end, end,
@ -2667,7 +2667,7 @@ set_affiliations(Host, Node, From, EntitiesEls) ->
Owners = node_owners_call(Host, Type, Nidx, O), Owners = node_owners_call(Host, Type, Nidx, O),
case lists:member(Owner, Owners) of case lists:member(Owner, Owners) of
true -> true ->
OwnerJID = jlib:make_jid(Owner), OwnerJID = jid:make(Owner),
FilteredEntities = case Owners of FilteredEntities = case Owners of
[Owner] -> [E || E <- Entities, element(1, E) =/= OwnerJID]; [Owner] -> [E || E <- Entities, element(1, E) =/= OwnerJID];
_ -> Entities _ -> Entities
@ -2676,13 +2676,13 @@ set_affiliations(Host, Node, From, EntitiesEls) ->
node_call(Host, Type, set_affiliation, [Nidx, JID, Affiliation]), node_call(Host, Type, set_affiliation, [Nidx, JID, Affiliation]),
case Affiliation of case Affiliation of
owner -> owner ->
NewOwner = jlib:jid_tolower(jlib:jid_remove_resource(JID)), NewOwner = jid:tolower(jid:remove_resource(JID)),
NewOwners = [NewOwner | Owners], NewOwners = [NewOwner | Owners],
tree_call(Host, tree_call(Host,
set_node, set_node,
[N#pubsub_node{owners = NewOwners}]); [N#pubsub_node{owners = NewOwners}]);
none -> none ->
OldOwner = jlib:jid_tolower(jlib:jid_remove_resource(JID)), OldOwner = jid:tolower(jid:remove_resource(JID)),
case lists:member(OldOwner, Owners) of case lists:member(OldOwner, Owners) of
true -> true ->
NewOwners = Owners -- [OldOwner], NewOwners = Owners -- [OldOwner],
@ -2756,7 +2756,7 @@ read_sub(Host, Node, Nidx, Subscriber, SubId, Lang) ->
[XdataEl] [XdataEl]
end, end,
OptionsEl = #xmlel{name = <<"options">>, OptionsEl = #xmlel{name = <<"options">>,
attrs = [{<<"jid">>, jlib:jid_to_string(Subscriber)}, attrs = [{<<"jid">>, jid:to_string(Subscriber)},
{<<"subid">>, SubId} {<<"subid">>, SubId}
| nodeAttr(Node)], | nodeAttr(Node)],
children = Children}, children = Children},
@ -2832,7 +2832,7 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) ->
unsupported, <<"retrieve-subscriptions">>)}, unsupported, <<"retrieve-subscriptions">>)},
Acc}; Acc};
true -> true ->
Subscriber = jlib:jid_remove_resource(JID), Subscriber = jid:remove_resource(JID),
{result, Subs} = node_action(Host, Type, {result, Subs} = node_action(Host, Type,
get_entity_subscriptions, get_entity_subscriptions,
[Host, Subscriber]), [Host, Subscriber]),
@ -2866,14 +2866,14 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) ->
<<>> -> <<>> ->
[#xmlel{name = <<"subscription">>, [#xmlel{name = <<"subscription">>,
attrs = attrs =
[{<<"jid">>, jlib:jid_to_string(SubJID)}, [{<<"jid">>, jid:to_string(SubJID)},
{<<"subid">>, SubId}, {<<"subid">>, SubId},
{<<"subscription">>, subscription_to_string(Sub)} {<<"subscription">>, subscription_to_string(Sub)}
| nodeAttr(SubsNode)]}]; | nodeAttr(SubsNode)]}];
SubsNode -> SubsNode ->
[#xmlel{name = <<"subscription">>, [#xmlel{name = <<"subscription">>,
attrs = attrs =
[{<<"jid">>, jlib:jid_to_string(SubJID)}, [{<<"jid">>, jid:to_string(SubJID)},
{<<"subid">>, SubId}, {<<"subid">>, SubId},
{<<"subscription">>, subscription_to_string(Sub)}]}]; {<<"subscription">>, subscription_to_string(Sub)}]}];
_ -> _ ->
@ -2884,13 +2884,13 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) ->
<<>> -> <<>> ->
[#xmlel{name = <<"subscription">>, [#xmlel{name = <<"subscription">>,
attrs = attrs =
[{<<"jid">>, jlib:jid_to_string(SubJID)}, [{<<"jid">>, jid:to_string(SubJID)},
{<<"subscription">>, subscription_to_string(Sub)} {<<"subscription">>, subscription_to_string(Sub)}
| nodeAttr(SubsNode)]}]; | nodeAttr(SubsNode)]}];
SubsNode -> SubsNode ->
[#xmlel{name = <<"subscription">>, [#xmlel{name = <<"subscription">>,
attrs = attrs =
[{<<"jid">>, jlib:jid_to_string(SubJID)}, [{<<"jid">>, jid:to_string(SubJID)},
{<<"subscription">>, subscription_to_string(Sub)}]}]; {<<"subscription">>, subscription_to_string(Sub)}]}];
_ -> _ ->
[] []
@ -2930,12 +2930,12 @@ get_subscriptions(Host, Node, JID) ->
({AJID, Sub}) -> ({AJID, Sub}) ->
[#xmlel{name = <<"subscription">>, [#xmlel{name = <<"subscription">>,
attrs = attrs =
[{<<"jid">>, jlib:jid_to_string(AJID)}, [{<<"jid">>, jid:to_string(AJID)},
{<<"subscription">>, subscription_to_string(Sub)}]}]; {<<"subscription">>, subscription_to_string(Sub)}]}];
({AJID, Sub, SubId}) -> ({AJID, Sub, SubId}) ->
[#xmlel{name = <<"subscription">>, [#xmlel{name = <<"subscription">>,
attrs = attrs =
[{<<"jid">>, jlib:jid_to_string(AJID)}, [{<<"jid">>, jid:to_string(AJID)},
{<<"subscription">>, subscription_to_string(Sub)}, {<<"subscription">>, subscription_to_string(Sub)},
{<<"subid">>, SubId}]}] {<<"subid">>, SubId}]}]
end, end,
@ -2974,18 +2974,18 @@ get_subscriptions_for_send_last(_Host, _PType, _, _JID, _LJID, _BJID) ->
[]. [].
set_subscriptions(Host, Node, From, EntitiesEls) -> set_subscriptions(Host, Node, From, EntitiesEls) ->
Owner = jlib:jid_tolower(jlib:jid_remove_resource(From)), Owner = jid:tolower(jid:remove_resource(From)),
Entities = lists:foldl(fun Entities = lists:foldl(fun
(_, error) -> (_, error) ->
error; error;
(El, Acc) -> (El, Acc) ->
case El of case El of
#xmlel{name = <<"subscription">>, attrs = Attrs} -> #xmlel{name = <<"subscription">>, attrs = Attrs} ->
JID = jlib:string_to_jid(xml:get_attr_s(<<"jid">>, Attrs)), JID = jid:from_string(xml:get_attr_s(<<"jid">>, Attrs)),
Sub = string_to_subscription(xml:get_attr_s(<<"subscription">>, Attrs)), Sub = string_to_subscription(xml:get_attr_s(<<"subscription">>, Attrs)),
SubId = xml:get_attr_s(<<"subid">>, Attrs), SubId = xml:get_attr_s(<<"subid">>, Attrs),
if (JID == error) or (Sub == false) -> error; if (JID == error) or (Sub == false) -> error;
true -> [{jlib:jid_tolower(JID), Sub, SubId} | Acc] true -> [{jid:tolower(JID), Sub, SubId} | Acc]
end end
end end
end, end,
@ -3001,10 +3001,10 @@ set_subscriptions(Host, Node, From, EntitiesEls) ->
attrs = [{<<"xmlns">>, ?NS_PUBSUB}], attrs = [{<<"xmlns">>, ?NS_PUBSUB}],
children = children =
[#xmlel{name = <<"subscription">>, [#xmlel{name = <<"subscription">>,
attrs = [{<<"jid">>, jlib:jid_to_string(JID)}, attrs = [{<<"jid">>, jid:to_string(JID)},
{<<"subscription">>, subscription_to_string(Sub)} {<<"subscription">>, subscription_to_string(Sub)}
| nodeAttr(Node)]}]}]}, | nodeAttr(Node)]}]}]},
ejabberd_router:route(service_jid(Host), jlib:make_jid(JID), Stanza) ejabberd_router:route(service_jid(Host), jid:make(JID), Stanza)
end, end,
Action = fun (#pubsub_node{type = Type, id = Nidx, owners = O}) -> Action = fun (#pubsub_node{type = Type, id = Nidx, owners = O}) ->
Owners = node_owners_call(Host, Type, Nidx, O), Owners = node_owners_call(Host, Type, Nidx, O),
@ -3076,7 +3076,7 @@ get_roster_info(OwnerUser, OwnerServer, {SubscriberUser, SubscriberServer, _}, A
Groups), Groups),
{PresenceSubscription, RosterGroup}; {PresenceSubscription, RosterGroup};
get_roster_info(OwnerUser, OwnerServer, JID, AllowedGroups) -> get_roster_info(OwnerUser, OwnerServer, JID, AllowedGroups) ->
get_roster_info(OwnerUser, OwnerServer, jlib:jid_tolower(JID), AllowedGroups). get_roster_info(OwnerUser, OwnerServer, jid:tolower(JID), AllowedGroups).
string_to_affiliation(<<"owner">>) -> owner; string_to_affiliation(<<"owner">>) -> owner;
string_to_affiliation(<<"publisher">>) -> publisher; string_to_affiliation(<<"publisher">>) -> publisher;
@ -3243,7 +3243,7 @@ items_event_stanza(Node, Items) ->
DateTime = calendar:now_to_datetime(ModifNow), DateTime = calendar:now_to_datetime(ModifNow),
{T_string, Tz_string} = jlib:timestamp_to_iso(DateTime, utc), {T_string, Tz_string} = jlib:timestamp_to_iso(DateTime, utc),
[#xmlel{name = <<"delay">>, attrs = [{<<"xmlns">>, ?NS_DELAY}, [#xmlel{name = <<"delay">>, attrs = [{<<"xmlns">>, ?NS_DELAY},
{<<"from">>, jlib:jid_to_string(ModifUSR)}, {<<"from">>, jid:to_string(ModifUSR)},
{<<"stamp">>, <<T_string/binary, Tz_string/binary>>}], {<<"stamp">>, <<T_string/binary, Tz_string/binary>>}],
children = [{xmlcdata, <<>>}]}]; children = [{xmlcdata, <<>>}]}];
_ -> _ ->
@ -3445,7 +3445,7 @@ broadcast_stanza(Host, _Node, _Nidx, _Type, NodeOptions, SubsByDepth, NotifyType
add_shim_headers(Stanza, subid_shim(SubIDs)) add_shim_headers(Stanza, subid_shim(SubIDs))
end, end,
lists:foreach(fun(To) -> lists:foreach(fun(To) ->
ejabberd_router:route(From, jlib:make_jid(To), StanzaToSend) ejabberd_router:route(From, jid:make(To), StanzaToSend)
end, LJIDs) end, LJIDs)
end, SubIDsByJID). end, SubIDsByJID).
@ -3462,9 +3462,9 @@ broadcast_stanza({LUser, LServer, LResource}, Publisher, Node, Nidx, Type, NodeO
%% See XEP-0163 1.1 section 4.3.1 %% See XEP-0163 1.1 section 4.3.1
ejabberd_c2s:broadcast(C2SPid, ejabberd_c2s:broadcast(C2SPid,
{pep_message, <<((Node))/binary, "+notify">>}, {pep_message, <<((Node))/binary, "+notify">>},
_Sender = jlib:make_jid(LUser, LServer, <<"">>), _Sender = jid:make(LUser, LServer, <<"">>),
_StanzaToSend = add_extended_headers(Stanza, _StanzaToSend = add_extended_headers(Stanza,
_ReplyTo = extended_headers([jlib:jid_to_string(Publisher)]))); _ReplyTo = extended_headers([jid:to_string(Publisher)])));
_ -> _ ->
?DEBUG("~p@~p has no session; can't deliver ~p to contacts", [LUser, LServer, BaseStanza]) ?DEBUG("~p@~p has no session; can't deliver ~p to contacts", [LUser, LServer, BaseStanza])
end; end;
@ -3684,8 +3684,8 @@ max_items(Host, Options) ->
-define(JLIST_CONFIG_FIELD(Label, Var, Opts), -define(JLIST_CONFIG_FIELD(Label, Var, Opts),
?LISTXFIELD(Label, ?LISTXFIELD(Label,
<<"pubsub#", (atom_to_binary(Var, latin1))/binary>>, <<"pubsub#", (atom_to_binary(Var, latin1))/binary>>,
(jlib:jid_to_string(get_option(Options, Var))), (jid:to_string(get_option(Options, Var))),
[jlib:jid_to_string(O) || O <- Opts])). [jid:to_string(O) || O <- Opts])).
-define(ALIST_CONFIG_FIELD(Label, Var, Opts), -define(ALIST_CONFIG_FIELD(Label, Var, Opts),
?LISTXFIELD(Label, ?LISTXFIELD(Label,
@ -3910,7 +3910,7 @@ set_cached_item({_, ServerHost, _}, Nidx, ItemId, Publisher, Payload) ->
set_cached_item(Host, Nidx, ItemId, Publisher, Payload) -> set_cached_item(Host, Nidx, ItemId, Publisher, Payload) ->
case is_last_item_cache_enabled(Host) of case is_last_item_cache_enabled(Host) of
true -> mnesia:dirty_write({pubsub_last_item, Nidx, ItemId, true -> mnesia:dirty_write({pubsub_last_item, Nidx, ItemId,
{now(), jlib:jid_tolower(jlib:jid_remove_resource(Publisher))}, {now(), jid:tolower(jid:remove_resource(Publisher))},
Payload}); Payload});
_ -> ok _ -> ok
end. end.
@ -4206,11 +4206,11 @@ extended_error(#xmlel{name = Error, attrs = Attrs, children = SubEls}, Ext, ExtA
children = lists:reverse([#xmlel{name = Ext, attrs = ExtAttrs} | SubEls])}. children = lists:reverse([#xmlel{name = Ext, attrs = ExtAttrs} | SubEls])}.
string_to_ljid(JID) -> string_to_ljid(JID) ->
case jlib:string_to_jid(JID) of case jid:from_string(JID) of
error -> error ->
{<<>>, <<>>, <<>>}; {<<>>, <<>>, <<>>};
J -> J ->
case jlib:jid_tolower(J) of case jid:tolower(J) of
error -> {<<>>, <<>>, <<>>}; error -> {<<>>, <<>>, <<>>};
J1 -> J1 J1 -> J1
end end
@ -4279,7 +4279,7 @@ extended_headers(Jids) ->
|| Jid <- Jids]. || Jid <- Jids].
on_user_offline(_, JID, _) -> on_user_offline(_, JID, _) ->
{User, Server, Resource} = jlib:jid_tolower(JID), {User, Server, Resource} = jid:tolower(JID),
case user_resources(User, Server) of case user_resources(User, Server) of
[] -> purge_offline({User, Server, Resource}); [] -> purge_offline({User, Server, Resource});
_ -> true _ -> true

View File

@ -89,19 +89,19 @@ unauthenticated_iq_register(_Acc, Server,
{A, _Port} -> A; {A, _Port} -> A;
_ -> undefined _ -> undefined
end, end,
ResIQ = process_iq(jlib:make_jid(<<"">>, <<"">>, ResIQ = process_iq(jid:make(<<"">>, <<"">>,
<<"">>), <<"">>),
jlib:make_jid(<<"">>, Server, <<"">>), IQ, Address), jid:make(<<"">>, Server, <<"">>), IQ, Address),
Res1 = jlib:replace_from_to(jlib:make_jid(<<"">>, Res1 = jlib:replace_from_to(jid:make(<<"">>,
Server, <<"">>), Server, <<"">>),
jlib:make_jid(<<"">>, <<"">>, <<"">>), jid:make(<<"">>, <<"">>, <<"">>),
jlib:iq_to_xml(ResIQ)), jlib:iq_to_xml(ResIQ)),
jlib:remove_attr(<<"to">>, Res1); jlib:remove_attr(<<"to">>, Res1);
unauthenticated_iq_register(Acc, _Server, _IQ, _IP) -> unauthenticated_iq_register(Acc, _Server, _IQ, _IP) ->
Acc. Acc.
process_iq(From, To, IQ) -> process_iq(From, To, IQ) ->
process_iq(From, To, IQ, jlib:jid_tolower(From)). process_iq(From, To, IQ, jid:tolower(From)).
process_iq(From, To, process_iq(From, To,
#iq{type = Type, lang = Lang, sub_el = SubEl, id = ID} = #iq{type = Type, lang = Lang, sub_el = SubEl, id = ID} =
@ -171,9 +171,9 @@ process_iq(From, To,
resource = Resource} -> resource = Resource} ->
ResIQ = #iq{type = result, xmlns = ?NS_REGISTER, ResIQ = #iq{type = result, xmlns = ?NS_REGISTER,
id = ID, sub_el = []}, id = ID, sub_el = []},
ejabberd_router:route(jlib:make_jid(User, Server, ejabberd_router:route(jid:make(User, Server,
Resource), Resource),
jlib:make_jid(User, Server, jid:make(User, Server,
Resource), Resource),
jlib:iq_to_xml(ResIQ)), jlib:iq_to_xml(ResIQ)),
ejabberd_auth:remove_user(User, Server), ejabberd_auth:remove_user(User, Server),
@ -373,10 +373,10 @@ try_set_password(User, Server, Password, IQ, SubEl,
end. end.
try_register(User, Server, Password, SourceRaw, Lang) -> try_register(User, Server, Password, SourceRaw, Lang) ->
case jlib:is_nodename(User) of case jid:is_nodename(User) of
false -> {error, ?ERR_BAD_REQUEST}; false -> {error, ?ERR_BAD_REQUEST};
_ -> _ ->
JID = jlib:make_jid(User, Server, <<"">>), JID = jid:make(User, Server, <<"">>),
Access = gen_mod:get_module_opt(Server, ?MODULE, access, Access = gen_mod:get_module_opt(Server, ?MODULE, access,
fun(A) when is_atom(A) -> A end, fun(A) when is_atom(A) -> A end,
all), all),
@ -441,7 +441,7 @@ send_welcome_message(JID) ->
of of
{<<"">>, <<"">>} -> ok; {<<"">>, <<"">>} -> ok;
{Subj, Body} -> {Subj, Body} ->
ejabberd_router:route(jlib:make_jid(<<"">>, Host, ejabberd_router:route(jid:make(<<"">>, Host,
<<"">>), <<"">>),
JID, JID,
#xmlel{name = <<"message">>, #xmlel{name = <<"message">>,
@ -463,7 +463,7 @@ send_registration_notifications(Mod, UJID, Source) ->
case gen_mod:get_module_opt( case gen_mod:get_module_opt(
Host, Mod, registration_watchers, Host, Mod, registration_watchers,
fun(Ss) -> fun(Ss) ->
[#jid{} = jlib:string_to_jid(iolist_to_binary(S)) [#jid{} = jid:from_string(iolist_to_binary(S))
|| S <- Ss] || S <- Ss]
end, []) of end, []) of
[] -> ok; [] -> ok;
@ -472,13 +472,13 @@ send_registration_notifications(Mod, UJID, Source) ->
iolist_to_binary(io_lib:format("[~s] The account ~s was registered from " iolist_to_binary(io_lib: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(),
jlib:jid_to_string(UJID), jid:to_string(UJID),
ip_to_string(Source), node(), ip_to_string(Source), node(),
Mod])), Mod])),
lists:foreach( lists:foreach(
fun(JID) -> fun(JID) ->
ejabberd_router:route( ejabberd_router:route(
jlib:make_jid(<<"">>, Host, <<"">>), jid:make(<<"">>, Host, <<"">>),
JID, JID,
#xmlel{name = <<"message">>, #xmlel{name = <<"message">>,
attrs = [{<<"type">>, <<"chat">>}], attrs = [{<<"type">>, <<"chat">>}],
@ -610,7 +610,7 @@ process_xdata_submit(El) ->
end. end.
is_strong_password(Server, Password) -> is_strong_password(Server, Password) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
case gen_mod:get_module_opt(LServer, ?MODULE, password_strength, case gen_mod:get_module_opt(LServer, ?MODULE, password_strength,
fun(N) when is_number(N), N>=0 -> N end, fun(N) when is_number(N), N>=0 -> N end,
0) of 0) of
@ -673,7 +673,7 @@ transform_module_options(Opts) ->
%%% %%%
may_remove_resource({_, _, _} = From) -> may_remove_resource({_, _, _} = From) ->
jlib:jid_remove_resource(From); jid:remove_resource(From);
may_remove_resource(From) -> From. may_remove_resource(From) -> From.
get_ip_access(Host) -> get_ip_access(Host) ->
@ -706,7 +706,7 @@ mod_opt_type(password_strength) ->
fun (N) when is_number(N), N >= 0 -> N end; fun (N) when is_number(N), N >= 0 -> N end;
mod_opt_type(registration_watchers) -> mod_opt_type(registration_watchers) ->
fun (Ss) -> fun (Ss) ->
[#jid{} = jlib:string_to_jid(iolist_to_binary(S)) [#jid{} = jid:from_string(iolist_to_binary(S))
|| S <- Ss] || S <- Ss]
end; end;
mod_opt_type(welcome_message) -> mod_opt_type(welcome_message) ->

View File

@ -100,7 +100,7 @@ process([<<"new">>],
lang = Lang, host = _HTTPHost}) -> lang = Lang, host = _HTTPHost}) ->
case form_new_post(Q) of case form_new_post(Q) of
{success, ok, {Username, Host, _Password}} -> {success, ok, {Username, Host, _Password}} ->
Jid = jlib:make_jid(Username, Host, <<"">>), Jid = jid:make(Username, Host, <<"">>),
mod_register:send_registration_notifications(?MODULE, Jid, Ip), mod_register:send_registration_notifications(?MODULE, Jid, Ip),
Text = (?T(<<"Your Jabber account was successfully " Text = (?T(<<"Your Jabber account was successfully "
"created.">>)), "created.">>)),
@ -491,7 +491,7 @@ register_account(Username, Host, Password) ->
Access = gen_mod:get_module_opt(Host, mod_register, access, Access = gen_mod:get_module_opt(Host, mod_register, access,
fun(A) when is_atom(A) -> A end, fun(A) when is_atom(A) -> A end,
all), all),
case jlib:make_jid(Username, Host, <<"">>) of case jid:make(Username, Host, <<"">>) of
error -> {error, invalid_jid}; error -> {error, invalid_jid};
JID -> JID ->
case acl:match_rule(Host, Access, JID) of case acl:match_rule(Host, Access, JID) of

View File

@ -396,7 +396,7 @@ get_roster(LUser, LServer, odbc) ->
error -> []; error -> [];
R -> R ->
SJID = SJID =
jlib:jid_to_string(R#roster.jid), jid:to_string(R#roster.jid),
Groups = case dict:find(SJID, Groups = case dict:find(SJID,
GroupsDict) GroupsDict)
of of
@ -413,7 +413,7 @@ get_roster(LUser, LServer, odbc) ->
item_to_xml(Item) -> item_to_xml(Item) ->
Attrs1 = [{<<"jid">>, Attrs1 = [{<<"jid">>,
jlib:jid_to_string(Item#roster.jid)}], jid:to_string(Item#roster.jid)}],
Attrs2 = case Item#roster.name of Attrs2 = case Item#roster.name of
<<"">> -> Attrs1; <<"">> -> Attrs1;
Name -> [{<<"name">>, Name} | Attrs1] Name -> [{<<"name">>, Name} | Attrs1]
@ -454,7 +454,7 @@ get_roster_by_jid_t(LUser, LServer, LJID, mnesia) ->
end; end;
get_roster_by_jid_t(LUser, LServer, LJID, odbc) -> get_roster_by_jid_t(LUser, LServer, LJID, odbc) ->
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)), SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
{selected, {selected,
[<<"username">>, <<"jid">>, <<"nick">>, [<<"username">>, <<"jid">>, <<"nick">>,
<<"subscription">>, <<"ask">>, <<"askmessage">>, <<"subscription">>, <<"ask">>, <<"askmessage">>,
@ -509,14 +509,14 @@ process_iq_set(From, To, #iq{sub_el = SubEl, id = Id} = IQ) ->
process_item_set(From, To, process_item_set(From, To,
#xmlel{attrs = Attrs, children = Els}, Managed) -> #xmlel{attrs = Attrs, children = Els}, Managed) ->
JID1 = jlib:string_to_jid(xml:get_attr_s(<<"jid">>, JID1 = jid:from_string(xml:get_attr_s(<<"jid">>,
Attrs)), Attrs)),
#jid{user = User, luser = LUser, lserver = LServer} = #jid{user = User, luser = LUser, lserver = LServer} =
From, From,
case JID1 of case JID1 of
error -> ok; error -> ok;
_ -> _ ->
LJID = jlib:jid_tolower(JID1), LJID = jid:tolower(JID1),
F = fun () -> F = fun () ->
Item = get_roster_by_jid_t(LUser, LServer, LJID), Item = get_roster_by_jid_t(LUser, LServer, LJID),
Item1 = process_item_attrs_managed(Item, Attrs, Managed), Item1 = process_item_attrs_managed(Item, Attrs, Managed),
@ -552,7 +552,7 @@ process_item_set(_From, _To, _, _Managed) -> ok.
process_item_attrs(Item, [{Attr, Val} | Attrs]) -> process_item_attrs(Item, [{Attr, Val} | Attrs]) ->
case Attr of case Attr of
<<"jid">> -> <<"jid">> ->
case jlib:string_to_jid(Val) of case jid:from_string(Val) of
error -> process_item_attrs(Item, Attrs); error -> process_item_attrs(Item, Attrs);
JID1 -> JID1 ->
JID = {JID1#jid.luser, JID1#jid.lserver, JID = {JID1#jid.luser, JID1#jid.lserver,
@ -595,8 +595,8 @@ process_item_els(Item, [{xmlcdata, _} | Els]) ->
process_item_els(Item, []) -> Item. process_item_els(Item, []) -> Item.
push_item(User, Server, From, Item) -> push_item(User, Server, From, Item) ->
ejabberd_sm:route(jlib:make_jid(<<"">>, <<"">>, <<"">>), ejabberd_sm:route(jid:make(<<"">>, <<"">>, <<"">>),
jlib:make_jid(User, Server, <<"">>), jid:make(User, Server, <<"">>),
{broadcast, {item, Item#roster.jid, {broadcast, {item, Item#roster.jid,
Item#roster.subscription}}), Item#roster.subscription}}),
case roster_versioning_enabled(Server) of case roster_versioning_enabled(Server) of
@ -629,7 +629,7 @@ push_item(User, Server, Resource, From, Item,
attrs = [{<<"xmlns">>, ?NS_ROSTER} | ExtraAttrs], attrs = [{<<"xmlns">>, ?NS_ROSTER} | ExtraAttrs],
children = [item_to_xml(Item)]}]}, children = [item_to_xml(Item)]}]},
ejabberd_router:route(From, ejabberd_router:route(From,
jlib:make_jid(User, Server, Resource), jid:make(User, Server, Resource),
jlib:iq_to_xml(ResIQ)). jlib:iq_to_xml(ResIQ)).
push_item_version(Server, User, From, Item, push_item_version(Server, User, From, Item,
@ -641,8 +641,8 @@ push_item_version(Server, User, From, Item,
ejabberd_sm:get_user_resources(User, Server)). ejabberd_sm:get_user_resources(User, Server)).
get_subscription_lists(Acc, User, Server) -> get_subscription_lists(Acc, User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
DBType = gen_mod:db_type(LServer, ?MODULE), DBType = gen_mod:db_type(LServer, ?MODULE),
Items = get_subscription_lists(Acc, LUser, LServer, Items = get_subscription_lists(Acc, LUser, LServer,
DBType), DBType),
@ -707,7 +707,7 @@ roster_subscribe_t(_LUser, _LServer, _LJID, Item,
roster_subscribe_t(LUser, LServer, LJID, Item, odbc) -> roster_subscribe_t(LUser, LServer, LJID, Item, odbc) ->
ItemVals = record_to_string(Item), ItemVals = record_to_string(Item),
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)), SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
odbc_queries:roster_subscribe(LServer, Username, SJID, odbc_queries:roster_subscribe(LServer, Username, SJID,
ItemVals); ItemVals);
roster_subscribe_t(LUser, LServer, _LJID, Item, riak) -> roster_subscribe_t(LUser, LServer, _LJID, Item, riak) ->
@ -744,7 +744,7 @@ get_roster_by_jid_with_groups_t(LUser, LServer, LJID,
get_roster_by_jid_with_groups_t(LUser, LServer, LJID, get_roster_by_jid_with_groups_t(LUser, LServer, LJID,
odbc) -> odbc) ->
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)), SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
case odbc_queries:get_roster_by_jid(LServer, Username, case odbc_queries:get_roster_by_jid(LServer, Username,
SJID) SJID)
of of
@ -783,9 +783,9 @@ get_roster_by_jid_with_groups_t(LUser, LServer, LJID, riak) ->
process_subscription(Direction, User, Server, JID1, process_subscription(Direction, User, Server, JID1,
Type, Reason) -> Type, Reason) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
LJID = jlib:jid_tolower(JID1), LJID = jid:tolower(JID1),
F = fun () -> F = fun () ->
Item = get_roster_by_jid_with_groups_t(LUser, LServer, Item = get_roster_by_jid_with_groups_t(LUser, LServer,
LJID), LJID),
@ -836,7 +836,7 @@ process_subscription(Direction, User, Server, JID1,
subscribed -> <<"subscribed">>; subscribed -> <<"subscribed">>;
unsubscribed -> <<"unsubscribed">> unsubscribed -> <<"unsubscribed">>
end, end,
ejabberd_router:route(jlib:make_jid(User, Server, ejabberd_router:route(jid:make(User, Server,
<<"">>), <<"">>),
JID1, JID1,
#xmlel{name = <<"presence">>, #xmlel{name = <<"presence">>,
@ -850,7 +850,7 @@ process_subscription(Direction, User, Server, JID1,
ok; ok;
true -> true ->
push_item(User, Server, push_item(User, Server,
jlib:make_jid(User, Server, <<"">>), Item) jid:make(User, Server, <<"">>), Item)
end, end,
true; true;
none -> false none -> false
@ -974,8 +974,8 @@ in_auto_reply(both, none, unsubscribe) -> unsubscribed;
in_auto_reply(_, _, _) -> none. in_auto_reply(_, _, _) -> none.
remove_user(User, Server) -> remove_user(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
send_unsubscription_to_rosteritems(LUser, LServer), send_unsubscription_to_rosteritems(LUser, LServer),
remove_user(LUser, LServer, remove_user(LUser, LServer,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -999,7 +999,7 @@ remove_user(LUser, LServer, riak) ->
%% Both or To, send a "unsubscribe" presence stanza. %% Both or To, send a "unsubscribe" presence stanza.
send_unsubscription_to_rosteritems(LUser, LServer) -> send_unsubscription_to_rosteritems(LUser, LServer) ->
RosterItems = get_user_roster([], {LUser, LServer}), RosterItems = get_user_roster([], {LUser, LServer}),
From = jlib:make_jid({LUser, LServer, <<"">>}), From = jid:make({LUser, LServer, <<"">>}),
lists:foreach(fun (RosterItem) -> lists:foreach(fun (RosterItem) ->
send_unsubscribing_presence(From, RosterItem) send_unsubscribing_presence(From, RosterItem)
end, end,
@ -1017,14 +1017,14 @@ send_unsubscribing_presence(From, Item) ->
_ -> false _ -> false
end, end,
if IsTo -> if IsTo ->
send_presence_type(jlib:jid_remove_resource(From), send_presence_type(jid:remove_resource(From),
jlib:make_jid(Item#roster.jid), jid:make(Item#roster.jid),
<<"unsubscribe">>); <<"unsubscribe">>);
true -> ok true -> ok
end, end,
if IsFrom -> if IsFrom ->
send_presence_type(jlib:jid_remove_resource(From), send_presence_type(jid:remove_resource(From),
jlib:make_jid(Item#roster.jid), jid:make(Item#roster.jid),
<<"unsubscribed">>); <<"unsubscribed">>);
true -> ok true -> ok
end, end,
@ -1039,8 +1039,8 @@ send_presence_type(From, To, Type) ->
set_items(User, Server, SubEl) -> set_items(User, Server, SubEl) ->
#xmlel{children = Els} = SubEl, #xmlel{children = Els} = SubEl,
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
F = fun () -> F = fun () ->
lists:foreach(fun (El) -> lists:foreach(fun (El) ->
process_item_set_t(LUser, LServer, El) process_item_set_t(LUser, LServer, El)
@ -1058,7 +1058,7 @@ update_roster_t(_LUser, _LServer, _LJID, Item,
mnesia:write(Item); mnesia:write(Item);
update_roster_t(LUser, LServer, LJID, Item, odbc) -> update_roster_t(LUser, LServer, LJID, Item, odbc) ->
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)), SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
ItemVals = record_to_string(Item), ItemVals = record_to_string(Item),
ItemGroups = groups_to_string(Item), ItemGroups = groups_to_string(Item),
odbc_queries:update_roster(LServer, Username, SJID, ItemVals, odbc_queries:update_roster(LServer, Username, SJID, ItemVals,
@ -1075,14 +1075,14 @@ del_roster_t(LUser, LServer, LJID, mnesia) ->
mnesia:delete({roster, {LUser, LServer, LJID}}); mnesia:delete({roster, {LUser, LServer, LJID}});
del_roster_t(LUser, LServer, LJID, odbc) -> del_roster_t(LUser, LServer, LJID, odbc) ->
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)), SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
odbc_queries:del_roster(LServer, Username, SJID); odbc_queries:del_roster(LServer, Username, SJID);
del_roster_t(LUser, LServer, LJID, riak) -> del_roster_t(LUser, LServer, LJID, riak) ->
ejabberd_riak:delete(roster, {LUser, LServer, LJID}). ejabberd_riak:delete(roster, {LUser, LServer, LJID}).
process_item_set_t(LUser, LServer, process_item_set_t(LUser, LServer,
#xmlel{attrs = Attrs, children = Els}) -> #xmlel{attrs = Attrs, children = Els}) ->
JID1 = jlib:string_to_jid(xml:get_attr_s(<<"jid">>, JID1 = jid:from_string(xml:get_attr_s(<<"jid">>,
Attrs)), Attrs)),
case JID1 of case JID1 of
error -> ok; error -> ok;
@ -1105,7 +1105,7 @@ process_item_set_t(_LUser, _LServer, _) -> ok.
process_item_attrs_ws(Item, [{Attr, Val} | Attrs]) -> process_item_attrs_ws(Item, [{Attr, Val} | Attrs]) ->
case Attr of case Attr of
<<"jid">> -> <<"jid">> ->
case jlib:string_to_jid(Val) of case jid:from_string(Val) of
error -> process_item_attrs_ws(Item, Attrs); error -> process_item_attrs_ws(Item, Attrs);
JID1 -> JID1 ->
JID = {JID1#jid.luser, JID1#jid.lserver, JID = {JID1#jid.luser, JID1#jid.lserver,
@ -1140,13 +1140,13 @@ process_item_attrs_ws(Item, [{Attr, Val} | Attrs]) ->
process_item_attrs_ws(Item, []) -> Item. process_item_attrs_ws(Item, []) -> Item.
get_in_pending_subscriptions(Ls, User, Server) -> get_in_pending_subscriptions(Ls, User, Server) ->
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
get_in_pending_subscriptions(Ls, User, Server, get_in_pending_subscriptions(Ls, User, Server,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
get_in_pending_subscriptions(Ls, User, Server, DBType) get_in_pending_subscriptions(Ls, User, Server, DBType)
when DBType == mnesia; DBType == riak -> when DBType == mnesia; DBType == riak ->
JID = jlib:make_jid(User, Server, <<"">>), JID = jid:make(User, Server, <<"">>),
Result = get_roster(JID#jid.luser, JID#jid.lserver, DBType), Result = get_roster(JID#jid.luser, JID#jid.lserver, DBType),
Ls ++ lists:map(fun (R) -> Ls ++ lists:map(fun (R) ->
Message = R#roster.askmessage, Message = R#roster.askmessage,
@ -1156,8 +1156,8 @@ get_in_pending_subscriptions(Ls, User, Server, DBType)
#xmlel{name = <<"presence">>, #xmlel{name = <<"presence">>,
attrs = attrs =
[{<<"from">>, [{<<"from">>,
jlib:jid_to_string(R#roster.jid)}, jid:to_string(R#roster.jid)},
{<<"to">>, jlib:jid_to_string(JID)}, {<<"to">>, jid:to_string(JID)},
{<<"type">>, <<"subscribe">>}], {<<"type">>, <<"subscribe">>}],
children = children =
[#xmlel{name = <<"status">>, [#xmlel{name = <<"status">>,
@ -1174,7 +1174,7 @@ get_in_pending_subscriptions(Ls, User, Server, DBType)
end, end,
Result)); Result));
get_in_pending_subscriptions(Ls, User, Server, odbc) -> get_in_pending_subscriptions(Ls, User, Server, odbc) ->
JID = jlib:make_jid(User, Server, <<"">>), JID = jid:make(User, Server, <<"">>),
LUser = JID#jid.luser, LUser = JID#jid.luser,
LServer = JID#jid.lserver, LServer = JID#jid.lserver,
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
@ -1191,8 +1191,8 @@ get_in_pending_subscriptions(Ls, User, Server, odbc) ->
#xmlel{name = <<"presence">>, #xmlel{name = <<"presence">>,
attrs = attrs =
[{<<"from">>, [{<<"from">>,
jlib:jid_to_string(R#roster.jid)}, jid:to_string(R#roster.jid)},
{<<"to">>, jlib:jid_to_string(JID)}, {<<"to">>, jid:to_string(JID)},
{<<"type">>, <<"subscribe">>}], {<<"type">>, <<"subscribe">>}],
children = children =
[#xmlel{name = <<"status">>, [#xmlel{name = <<"status">>,
@ -1219,8 +1219,8 @@ get_in_pending_subscriptions(Ls, User, Server, odbc) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
read_subscription_and_groups(User, Server, LJID) -> read_subscription_and_groups(User, Server, LJID) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
read_subscription_and_groups(LUser, LServer, LJID, read_subscription_and_groups(LUser, LServer, LJID,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
@ -1237,7 +1237,7 @@ read_subscription_and_groups(LUser, LServer, LJID,
read_subscription_and_groups(LUser, LServer, LJID, read_subscription_and_groups(LUser, LServer, LJID,
odbc) -> odbc) ->
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)), SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
case catch odbc_queries:get_subscription(LServer, case catch odbc_queries:get_subscription(LServer,
Username, SJID) Username, SJID)
of of
@ -1270,11 +1270,11 @@ read_subscription_and_groups(LUser, LServer, LJID,
end. end.
get_jid_info(_, User, Server, JID) -> get_jid_info(_, User, Server, JID) ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
case read_subscription_and_groups(User, Server, LJID) of case read_subscription_and_groups(User, Server, LJID) of
{Subscription, Groups} -> {Subscription, Groups}; {Subscription, Groups} -> {Subscription, Groups};
error -> error ->
LRJID = jlib:jid_tolower(jlib:jid_remove_resource(JID)), LRJID = jid:tolower(jid:remove_resource(JID)),
if LRJID == LJID -> {none, []}; if LRJID == LJID -> {none, []};
true -> true ->
case read_subscription_and_groups(User, Server, LRJID) case read_subscription_and_groups(User, Server, LRJID)
@ -1290,10 +1290,10 @@ get_jid_info(_, User, Server, JID) ->
raw_to_record(LServer, raw_to_record(LServer,
[User, SJID, Nick, SSubscription, SAsk, SAskMessage, [User, SJID, Nick, SSubscription, SAsk, SAskMessage,
_SServer, _SSubscribe, _SType]) -> _SServer, _SSubscribe, _SType]) ->
case jlib:string_to_jid(SJID) of case jid:from_string(SJID) of
error -> error; error -> error;
JID -> JID ->
LJID = jlib:jid_tolower(JID), LJID = jid:tolower(JID),
Subscription = case SSubscription of Subscription = case SSubscription of
<<"B">> -> both; <<"B">> -> both;
<<"T">> -> to; <<"T">> -> to;
@ -1319,7 +1319,7 @@ record_to_string(#roster{us = {User, _Server},
ask = Ask, askmessage = AskMessage}) -> ask = Ask, askmessage = AskMessage}) ->
Username = ejabberd_odbc:escape(User), Username = ejabberd_odbc:escape(User),
SJID = SJID =
ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(JID))), ejabberd_odbc:escape(jid:to_string(jid:tolower(JID))),
Nick = ejabberd_odbc:escape(Name), Nick = ejabberd_odbc:escape(Name),
SSubscription = case Subscription of SSubscription = case Subscription of
both -> <<"B">>; both -> <<"B">>;
@ -1343,7 +1343,7 @@ groups_to_string(#roster{us = {User, _Server},
jid = JID, groups = Groups}) -> jid = JID, groups = Groups}) ->
Username = ejabberd_odbc:escape(User), Username = ejabberd_odbc:escape(User),
SJID = SJID =
ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(JID))), ejabberd_odbc:escape(jid:to_string(jid:tolower(JID))),
lists:foldl(fun (<<"">>, Acc) -> Acc; lists:foldl(fun (<<"">>, Acc) -> Acc;
(Group, Acc) -> (Group, Acc) ->
G = ejabberd_odbc:escape(Group), G = ejabberd_odbc:escape(Group),
@ -1417,8 +1417,8 @@ webadmin_page(_, Host,
webadmin_page(Acc, _, _) -> Acc. webadmin_page(Acc, _, _) -> Acc.
user_roster(User, Server, Query, Lang) -> user_roster(User, Server, Query, Lang) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
Items1 = get_roster(LUser, LServer), Items1 = get_roster(LUser, LServer),
Res = user_roster_parse_query(User, Server, Items1, Res = user_roster_parse_query(User, Server, Items1,
@ -1504,7 +1504,7 @@ user_roster(User, Server, Query, Lang) ->
<<"Add Jabber ID">>)]))]. <<"Add Jabber ID">>)]))].
build_contact_jid_td(RosterJID) -> build_contact_jid_td(RosterJID) ->
ContactJID = jlib:make_jid(RosterJID), ContactJID = jid:make(RosterJID),
JIDURI = case {ContactJID#jid.luser, JIDURI = case {ContactJID#jid.luser,
ContactJID#jid.lserver} ContactJID#jid.lserver}
of of
@ -1520,10 +1520,10 @@ build_contact_jid_td(RosterJID) ->
case JIDURI of case JIDURI of
<<>> -> <<>> ->
?XAC(<<"td">>, [{<<"class">>, <<"valign">>}], ?XAC(<<"td">>, [{<<"class">>, <<"valign">>}],
(jlib:jid_to_string(RosterJID))); (jid:to_string(RosterJID)));
URI when is_binary(URI) -> URI when is_binary(URI) ->
?XAE(<<"td">>, [{<<"class">>, <<"valign">>}], ?XAE(<<"td">>, [{<<"class">>, <<"valign">>}],
[?AC(JIDURI, (jlib:jid_to_string(RosterJID)))]) [?AC(JIDURI, (jid:to_string(RosterJID)))])
end. end.
user_roster_parse_query(User, Server, Items, Query) -> user_roster_parse_query(User, Server, Items, Query) ->
@ -1531,7 +1531,7 @@ user_roster_parse_query(User, Server, Items, Query) ->
{value, _} -> {value, _} ->
case lists:keysearch(<<"newjid">>, 1, Query) of case lists:keysearch(<<"newjid">>, 1, Query) of
{value, {_, SJID}} -> {value, {_, SJID}} ->
case jlib:string_to_jid(SJID) of case jid:from_string(SJID) of
JID when is_record(JID, jid) -> JID when is_record(JID, jid) ->
user_roster_subscribe_jid(User, Server, JID), ok; user_roster_subscribe_jid(User, Server, JID), ok;
error -> error error -> error
@ -1550,7 +1550,7 @@ user_roster_parse_query(User, Server, Items, Query) ->
user_roster_subscribe_jid(User, Server, JID) -> user_roster_subscribe_jid(User, Server, JID) ->
out_subscription(User, Server, JID, subscribe), out_subscription(User, Server, JID, subscribe),
UJID = jlib:make_jid(User, Server, <<"">>), UJID = jid:make(User, Server, <<"">>),
ejabberd_router:route(UJID, JID, ejabberd_router:route(UJID, JID,
#xmlel{name = <<"presence">>, #xmlel{name = <<"presence">>,
attrs = [{<<"type">>, <<"subscribe">>}], attrs = [{<<"type">>, <<"subscribe">>}],
@ -1565,10 +1565,10 @@ user_roster_item_parse_query(User, Server, Items,
1, Query) 1, Query)
of of
{value, _} -> {value, _} ->
JID1 = jlib:make_jid(JID), JID1 = jid:make(JID),
out_subscription(User, Server, JID1, out_subscription(User, Server, JID1,
subscribed), subscribed),
UJID = jlib:make_jid(User, Server, <<"">>), UJID = jid:make(User, Server, <<"">>),
ejabberd_router:route(UJID, JID1, ejabberd_router:route(UJID, JID1,
#xmlel{name = #xmlel{name =
<<"presence">>, <<"presence">>,
@ -1583,7 +1583,7 @@ user_roster_item_parse_query(User, Server, Items,
1, Query) 1, Query)
of of
{value, _} -> {value, _} ->
UJID = jlib:make_jid(User, Server, UJID = jid:make(User, Server,
<<"">>), <<"">>),
process_iq_set(UJID, UJID, process_iq_set(UJID, UJID,
#iq{type = set, #iq{type = set,
@ -1600,7 +1600,7 @@ user_roster_item_parse_query(User, Server, Items,
attrs attrs
= =
[{<<"jid">>, [{<<"jid">>,
jlib:jid_to_string(JID)}, jid:to_string(JID)},
{<<"subscription">>, {<<"subscription">>,
<<"remove">>}], <<"remove">>}],
children children
@ -1615,7 +1615,7 @@ user_roster_item_parse_query(User, Server, Items,
nothing. nothing.
us_to_list({User, Server}) -> us_to_list({User, Server}) ->
jlib:jid_to_string({User, Server, <<"">>}). jid:to_string({User, Server, <<"">>}).
webadmin_user(Acc, _User, _Server, Lang) -> webadmin_user(Acc, _User, _Server, Lang) ->
Acc ++ Acc ++
@ -1676,7 +1676,7 @@ is_item_of_domain(_MatchDomain, {xmlcdata, _}) ->
false. false.
is_jid_of_domain(MatchDomain, {<<"jid">>, JIDString}) -> is_jid_of_domain(MatchDomain, {<<"jid">>, JIDString}) ->
case jlib:string_to_jid(JIDString) of case jid:from_string(JIDString) of
JID when JID#jid.lserver == MatchDomain -> true; JID when JID#jid.lserver == MatchDomain -> true;
_ -> false _ -> false
end; end;
@ -1716,7 +1716,7 @@ export(_Server) ->
fun(Host, #roster{usj = {LUser, LServer, LJID}} = R) fun(Host, #roster{usj = {LUser, LServer, LJID}} = R)
when LServer == Host -> when LServer == Host ->
Username = ejabberd_odbc:escape(LUser), Username = ejabberd_odbc:escape(LUser),
SJID = ejabberd_odbc:escape(jlib:jid_to_string(LJID)), SJID = ejabberd_odbc:escape(jid:to_string(LJID)),
ItemVals = record_to_string(R), ItemVals = record_to_string(R),
ItemGroups = groups_to_string(R), ItemGroups = groups_to_string(R),
odbc_queries:update_roster_sql(Username, SJID, odbc_queries:update_roster_sql(Username, SJID,

View File

@ -67,7 +67,7 @@ log_packet(From, To,
lists:map( lists:map(
fun(S) -> fun(S) ->
B = iolist_to_binary(S), B = iolist_to_binary(S),
N = jlib:nameprep(B), N = jid:nameprep(B),
if N /= error -> if N /= error ->
N N
end end
@ -77,8 +77,8 @@ log_packet(From, To,
resource = <<"">>, luser = <<"">>, lserver = Host, resource = <<"">>, luser = <<"">>, lserver = Host,
lresource = <<"">>}, lresource = <<"">>},
NewAttrs = NewAttrs =
jlib:replace_from_to_attrs(jlib:jid_to_string(From), jlib:replace_from_to_attrs(jid:to_string(From),
jlib:jid_to_string(To), Attrs), jid:to_string(To), Attrs),
FixedPacket = #xmlel{name = Name, attrs = NewAttrs, FixedPacket = #xmlel{name = Name, attrs = NewAttrs,
children = Els}, children = Els},
lists:foreach(fun (Logger) -> lists:foreach(fun (Logger) ->
@ -100,7 +100,7 @@ mod_opt_type(loggers) ->
fun (L) -> fun (L) ->
lists:map(fun (S) -> lists:map(fun (S) ->
B = iolist_to_binary(S), B = iolist_to_binary(S),
N = jlib:nameprep(B), N = jid:nameprep(B),
if N /= error -> N end if N /= error -> N end
end, end,
L) L)

View File

@ -182,8 +182,8 @@ get_vcard_module(Server) ->
get_rosteritem_name([], _, _) -> <<"">>; get_rosteritem_name([], _, _) -> <<"">>;
get_rosteritem_name([ModVcard], U, S) -> get_rosteritem_name([ModVcard], U, S) ->
From = jlib:make_jid(<<"">>, S, jlib:atom_to_binary(?MODULE)), From = jid:make(<<"">>, S, jlib:atom_to_binary(?MODULE)),
To = jlib:make_jid(U, S, <<"">>), To = jid:make(U, S, <<"">>),
case lists:member(To#jid.lserver, ?MYHOSTS) of case lists:member(To#jid.lserver, ?MYHOSTS) of
true -> true ->
IQ = {iq, <<"">>, get, <<"vcard-temp">>, <<"">>, IQ = {iq, <<"">>, get, <<"vcard-temp">>, <<"">>,
@ -246,11 +246,11 @@ process_item(RosterItem, Host) ->
%% existing roster groups. %% existing roster groups.
[] -> [] ->
mod_roster:out_subscription(UserTo, ServerTo, mod_roster:out_subscription(UserTo, ServerTo,
jlib:make_jid(UserFrom, ServerFrom, jid:make(UserFrom, ServerFrom,
<<"">>), <<"">>),
unsubscribe), unsubscribe),
mod_roster:in_subscription(aaaa, UserFrom, ServerFrom, mod_roster:in_subscription(aaaa, UserFrom, ServerFrom,
jlib:make_jid(UserTo, ServerTo, jid:make(UserTo, ServerTo,
<<"">>), <<"">>),
unsubscribe, <<"">>), unsubscribe, <<"">>),
RosterItem#roster{subscription = both, ask = none}; RosterItem#roster{subscription = both, ask = none};
@ -275,8 +275,8 @@ set_new_rosteritems(UserFrom, ServerFrom, UserTo,
RIFrom = build_roster_record(UserFrom, ServerFrom, RIFrom = build_roster_record(UserFrom, ServerFrom,
UserTo, ServerTo, NameTo, GroupsFrom), UserTo, ServerTo, NameTo, GroupsFrom),
set_item(UserFrom, ServerFrom, ResourceTo, RIFrom), set_item(UserFrom, ServerFrom, ResourceTo, RIFrom),
JIDTo = jlib:make_jid(UserTo, ServerTo, <<"">>), JIDTo = jid:make(UserTo, ServerTo, <<"">>),
JIDFrom = jlib:make_jid(UserFrom, ServerFrom, <<"">>), JIDFrom = jid:make(UserFrom, ServerFrom, <<"">>),
RITo = build_roster_record(UserTo, ServerTo, UserFrom, RITo = build_roster_record(UserTo, ServerTo, UserFrom,
ServerFrom, UserFrom, []), ServerFrom, UserFrom, []),
set_item(UserTo, ServerTo, <<"">>, RITo), set_item(UserTo, ServerTo, <<"">>, RITo),
@ -305,14 +305,14 @@ set_item(User, Server, Resource, Item) ->
[#xmlel{name = <<"query">>, [#xmlel{name = <<"query">>,
attrs = [{<<"xmlns">>, ?NS_ROSTER}], attrs = [{<<"xmlns">>, ?NS_ROSTER}],
children = [mod_roster:item_to_xml(Item)]}]}, children = [mod_roster:item_to_xml(Item)]}]},
ejabberd_router:route(jlib:make_jid(User, Server, ejabberd_router:route(jid:make(User, Server,
Resource), Resource),
jlib:make_jid(<<"">>, Server, <<"">>), jid:make(<<"">>, Server, <<"">>),
jlib:iq_to_xml(ResIQ)). jlib:iq_to_xml(ResIQ)).
get_subscription_lists({F, T}, User, Server) -> get_subscription_lists({F, T}, User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
DisplayedGroups = get_user_displayed_groups(US), DisplayedGroups = get_user_displayed_groups(US),
SRUsers = lists:usort(lists:flatmap(fun (Group) -> SRUsers = lists:usort(lists:flatmap(fun (Group) ->
@ -324,10 +324,10 @@ get_subscription_lists({F, T}, User, Server) ->
get_jid_info({Subscription, Groups}, User, Server, get_jid_info({Subscription, Groups}, User, Server,
JID) -> JID) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
{U1, S1, _} = jlib:jid_tolower(JID), {U1, S1, _} = jid:tolower(JID),
US1 = {U1, S1}, US1 = {U1, S1},
DisplayedGroups = get_user_displayed_groups(US), DisplayedGroups = get_user_displayed_groups(US),
SRUsers = lists:foldl(fun (Group, Acc1) -> SRUsers = lists:foldl(fun (Group, Acc1) ->
@ -357,7 +357,7 @@ in_subscription(Acc, User, Server, JID, Type,
out_subscription(UserFrom, ServerFrom, JIDTo, out_subscription(UserFrom, ServerFrom, JIDTo,
unsubscribed) -> unsubscribed) ->
#jid{luser = UserTo, lserver = ServerTo} = JIDTo, #jid{luser = UserTo, lserver = ServerTo} = JIDTo,
JIDFrom = jlib:make_jid(UserFrom, ServerFrom, <<"">>), JIDFrom = jid:make(UserFrom, ServerFrom, <<"">>),
mod_roster:out_subscription(UserTo, ServerTo, JIDFrom, mod_roster:out_subscription(UserTo, ServerTo, JIDFrom,
unsubscribe), unsubscribe),
mod_roster:in_subscription(aaaa, UserFrom, ServerFrom, mod_roster:in_subscription(aaaa, UserFrom, ServerFrom,
@ -370,11 +370,11 @@ out_subscription(User, Server, JID, Type) ->
process_subscription(Direction, User, Server, JID, process_subscription(Direction, User, Server, JID,
_Type, Acc) -> _Type, Acc) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
{U1, S1, _} = {U1, S1, _} =
jlib:jid_tolower(jlib:jid_remove_resource(JID)), jid:tolower(jid:remove_resource(JID)),
US1 = {U1, S1}, US1 = {U1, S1},
DisplayedGroups = get_user_displayed_groups(US), DisplayedGroups = get_user_displayed_groups(US),
SRUsers = lists:usort(lists:flatmap(fun (Group) -> SRUsers = lists:usort(lists:flatmap(fun (Group) ->
@ -657,7 +657,7 @@ get_group_explicit_users(Host, Group, odbc) ->
{selected, [<<"jid">>], Rs} -> {selected, [<<"jid">>], Rs} ->
lists:map(fun ([JID]) -> lists:map(fun ([JID]) ->
{U, S, _} = {U, S, _} =
jlib:jid_tolower(jlib:string_to_jid(JID)), jid:tolower(jid:from_string(JID)),
{U, S} {U, S}
end, end,
Rs); Rs);
@ -949,8 +949,8 @@ remove_user(User, Server) ->
push_user_to_members(User, Server, remove). push_user_to_members(User, Server, remove).
push_user_to_members(User, Server, Subscription) -> push_user_to_members(User, Server, Subscription) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
GroupsOpts = groups_with_opts(LServer), GroupsOpts = groups_with_opts(LServer),
SpecialGroups = SpecialGroups =
get_special_displayed_groups(GroupsOpts), get_special_displayed_groups(GroupsOpts),
@ -1024,8 +1024,8 @@ push_item(User, Server, Item) ->
attrs = [{<<"xmlns">>, ?NS_ROSTER}], attrs = [{<<"xmlns">>, ?NS_ROSTER}],
children = [item_to_xml(Item)]}]}), children = [item_to_xml(Item)]}]}),
lists:foreach(fun (Resource) -> lists:foreach(fun (Resource) ->
JID = jlib:make_jid(User, Server, Resource), JID = jid:make(User, Server, Resource),
ejabberd_router:route(jlib:jid_remove_resource(JID), JID, Stanza) ejabberd_router:route(jid:remove_resource(JID), JID, Stanza)
end, end,
ejabberd_sm:get_user_resources(User, Server)). ejabberd_sm:get_user_resources(User, Server)).
@ -1040,7 +1040,7 @@ push_roster_item(User, Server, ContactU, ContactS,
item_to_xml(Item) -> item_to_xml(Item) ->
Attrs1 = [{<<"jid">>, Attrs1 = [{<<"jid">>,
jlib:jid_to_string(Item#roster.jid)}], jid:to_string(Item#roster.jid)}],
Attrs2 = case Item#roster.name of Attrs2 = case Item#roster.name of
<<"">> -> Attrs1; <<"">> -> Attrs1;
Name -> [{<<"name">>, Name} | Attrs1] Name -> [{<<"name">>, Name} | Attrs1]
@ -1298,7 +1298,7 @@ shared_roster_group_parse_query(Host, Group, Query) ->
<<"@all@">> -> USs; <<"@all@">> -> USs;
<<"@online@">> -> USs; <<"@online@">> -> USs;
_ -> _ ->
case jlib:string_to_jid(SJID) case jid:from_string(SJID)
of of
JID JID
when is_record(JID, when is_record(JID,
@ -1358,7 +1358,7 @@ get_opt(Opts, Opt, Default) ->
end. end.
us_to_list({User, Server}) -> us_to_list({User, Server}) ->
jlib:jid_to_string({User, Server, <<"">>}). jid:to_string({User, Server, <<"">>}).
split_grouphost(Host, Group) -> split_grouphost(Host, Group) ->
case str:tokens(Group, <<"@">>) of case str:tokens(Group, <<"@">>) of
@ -1368,8 +1368,8 @@ split_grouphost(Host, Group) ->
broadcast_subscription(User, Server, ContactJid, Subscription) -> broadcast_subscription(User, Server, ContactJid, Subscription) ->
ejabberd_sm:route( ejabberd_sm:route(
jlib:make_jid(<<"">>, Server, <<"">>), jid:make(<<"">>, Server, <<"">>),
jlib:make_jid(User, Server, <<"">>), jid:make(User, Server, <<"">>),
{broadcast, {item, ContactJid, {broadcast, {item, ContactJid,
Subscription}}). Subscription}}).
@ -1386,7 +1386,7 @@ displayed_groups_update(Members, DisplayedGroups, Subscription) ->
end, Members). end, Members).
make_jid_s(U, S) -> make_jid_s(U, S) ->
ejabberd_odbc:escape(jlib:jid_to_string(jlib:jid_tolower(jlib:make_jid(U, ejabberd_odbc:escape(jid:to_string(jid:tolower(jid:make(U,
S, S,
<<"">>)))). <<"">>)))).
@ -1466,9 +1466,9 @@ export(_Server) ->
when LServer == Host -> when LServer == Host ->
SGroup = ejabberd_odbc:escape(Group), SGroup = ejabberd_odbc:escape(Group),
SJID = ejabberd_odbc:escape( SJID = ejabberd_odbc:escape(
jlib:jid_to_string( jid:to_string(
jlib:jid_tolower( jid:tolower(
jlib:make_jid(U, S, <<"">>)))), jid:make(U, S, <<"">>)))),
[[<<"delete from sr_user where jid='">>, SJID, [[<<"delete from sr_user where jid='">>, SJID,
<<"'and grp='">>, Group, <<"';">>], <<"'and grp='">>, Group, <<"';">>],
[<<"insert into sr_user(jid, grp) values ('">>, [<<"insert into sr_user(jid, grp) values ('">>,
@ -1485,7 +1485,7 @@ import(LServer) ->
end}, end},
{<<"select jid, grp from sr_user;">>, {<<"select jid, grp from sr_user;">>,
fun([SJID, Group]) -> fun([SJID, Group]) ->
#jid{luser = U, lserver = S} = jlib:string_to_jid(SJID), #jid{luser = U, lserver = S} = jid:from_string(SJID),
#sr_user{us = {U, S}, group_host = {Group, LServer}} #sr_user{us = {U, S}, group_host = {Group, LServer}}
end}]. end}].

View File

@ -159,8 +159,8 @@ process_item(RosterItem, _Host) ->
end. end.
get_subscription_lists({F, T}, User, Server) -> get_subscription_lists({F, T}, User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
DisplayedGroups = get_user_displayed_groups(US), DisplayedGroups = get_user_displayed_groups(US),
SRUsers = lists:usort(lists:flatmap(fun (Group) -> SRUsers = lists:usort(lists:flatmap(fun (Group) ->
@ -172,10 +172,10 @@ get_subscription_lists({F, T}, User, Server) ->
get_jid_info({Subscription, Groups}, User, Server, get_jid_info({Subscription, Groups}, User, Server,
JID) -> JID) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
{U1, S1, _} = jlib:jid_tolower(JID), {U1, S1, _} = jid:tolower(JID),
US1 = {U1, S1}, US1 = {U1, S1},
SRUsers = get_user_to_groups_map(US, false), SRUsers = get_user_to_groups_map(US, false),
case dict:find(US1, SRUsers) of case dict:find(US1, SRUsers) of
@ -197,11 +197,11 @@ out_subscription(User, Server, JID, Type) ->
process_subscription(Direction, User, Server, JID, process_subscription(Direction, User, Server, JID,
_Type, Acc) -> _Type, Acc) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
US = {LUser, LServer}, US = {LUser, LServer},
{U1, S1, _} = {U1, S1, _} =
jlib:jid_tolower(jlib:jid_remove_resource(JID)), jid:tolower(jid:remove_resource(JID)),
US1 = {U1, S1}, US1 = {U1, S1},
DisplayedGroups = get_user_displayed_groups(US), DisplayedGroups = get_user_displayed_groups(US),
SRUsers = lists:usort(lists:flatmap(fun (Group) -> SRUsers = lists:usort(lists:flatmap(fun (Group) ->
@ -417,7 +417,7 @@ search_group_info(State, Group) ->
UID}, UID},
L) -> L) ->
PUID = PUID =
jlib:nodeprep(UID), jid:nodeprep(UID),
case case
PUID PUID
of of

View File

@ -160,8 +160,8 @@ locate(_SIPMsg) ->
ok. ok.
find(#uri{user = User, host = Host}) -> find(#uri{user = User, host = Host}) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Host), LServer = jid:nameprep(Host),
if LUser == <<"">> -> if LUser == <<"">> ->
to_me; to_me;
true -> true ->
@ -192,7 +192,7 @@ action(#sip{method = <<"REGISTER">>, type = request, hdrs = Hdrs,
true -> true ->
register; register;
false -> false ->
{auth, jlib:nameprep(ToURI#uri.host)} {auth, jid:nameprep(ToURI#uri.host)}
end; end;
false -> false ->
deny deny
@ -223,7 +223,7 @@ action(#sip{method = Method, hdrs = Hdrs, type = request} = Req, SIPSock) ->
true -> true ->
find(ToURI); find(ToURI);
false -> false ->
LServer = jlib:nameprep(FromURI#uri.host), LServer = jid:nameprep(FromURI#uri.host),
{relay, LServer} {relay, LServer}
end; end;
false -> false ->
@ -250,8 +250,8 @@ check_auth(#sip{method = Method, hdrs = Hdrs, body = Body}, AuthHdr, _SIPSock) -
from from
end, end,
{_, #uri{user = User, host = Host}, _} = esip:get_hdr(Issuer, Hdrs), {_, #uri{user = User, host = Host}, _} = esip:get_hdr(Issuer, Hdrs),
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Host), LServer = jid:nameprep(Host),
case lists:filter( case lists:filter(
fun({_, Params}) -> fun({_, Params}) ->
Username = esip:get_param(<<"username">>, Params), Username = esip:get_param(<<"username">>, Params),
@ -299,7 +299,7 @@ make_response(Req, Resp) ->
esip:make_response(Req, Resp, esip:make_tag()). esip:make_response(Req, Resp, esip:make_tag()).
at_my_host(#uri{host = Host}) -> at_my_host(#uri{host = Host}) ->
is_my_host(jlib:nameprep(Host)). is_my_host(jid:nameprep(Host)).
is_my_host(LServer) -> is_my_host(LServer) ->
gen_mod:is_loaded(LServer, ?MODULE). gen_mod:is_loaded(LServer, ?MODULE).

View File

@ -249,8 +249,8 @@ connect(#sip{hdrs = Hdrs} = Req, Opts) ->
{_, ToURI, _} = esip:get_hdr('to', Hdrs), {_, ToURI, _} = esip:get_hdr('to', Hdrs),
case mod_sip:at_my_host(ToURI) of case mod_sip:at_my_host(ToURI) of
true -> true ->
LUser = jlib:nodeprep(ToURI#uri.user), LUser = jid:nodeprep(ToURI#uri.user),
LServer = jlib:nameprep(ToURI#uri.host), LServer = jid:nameprep(ToURI#uri.host),
case mod_sip_registrar:find_sockets(LUser, LServer) of case mod_sip_registrar:find_sockets(LUser, LServer) of
[_|_] = SIPSocks -> [_|_] = SIPSocks ->
{ok, SIPSocks}; {ok, SIPSocks};
@ -412,7 +412,7 @@ choose_best_response(#state{responses = Responses} = State) ->
%% Just compare host part only. %% Just compare host part only.
cmp_uri(#uri{host = H1}, #uri{host = H2}) -> cmp_uri(#uri{host = H1}, #uri{host = H2}) ->
jlib:nameprep(H1) == jlib:nameprep(H2). jid:nameprep(H1) == jid:nameprep(H2).
is_my_route(URI, URIs) -> is_my_route(URI, URIs) ->
lists:any(fun(U) -> cmp_uri(URI, U) end, URIs). lists:any(fun(U) -> cmp_uri(URI, U) end, URIs).
@ -441,20 +441,20 @@ prepare_request(LServer, #sip{hdrs = Hdrs} = Req) ->
Hdrs3 = lists:filter( Hdrs3 = lists:filter(
fun({'proxy-authorization', {_, Params}}) -> fun({'proxy-authorization', {_, Params}}) ->
Realm = esip:unquote(esip:get_param(<<"realm">>, Params)), Realm = esip:unquote(esip:get_param(<<"realm">>, Params)),
not mod_sip:is_my_host(jlib:nameprep(Realm)); not mod_sip:is_my_host(jid:nameprep(Realm));
(_) -> (_) ->
true true
end, Hdrs2), end, Hdrs2),
Req#sip{hdrs = Hdrs3}. Req#sip{hdrs = Hdrs3}.
safe_nodeprep(S) -> safe_nodeprep(S) ->
case jlib:nodeprep(S) of case jid:nodeprep(S) of
error -> S; error -> S;
S1 -> S1 S1 -> S1
end. end.
safe_nameprep(S) -> safe_nameprep(S) ->
case jlib:nameprep(S) of case jid:nameprep(S) of
error -> S; error -> S;
S1 -> S1 S1 -> S1
end. end.

View File

@ -65,8 +65,8 @@ start_link() ->
request(#sip{hdrs = Hdrs} = Req, SIPSock) -> request(#sip{hdrs = Hdrs} = Req, SIPSock) ->
{_, #uri{user = U, host = S}, _} = esip:get_hdr('to', Hdrs), {_, #uri{user = U, host = S}, _} = esip:get_hdr('to', Hdrs),
LUser = jlib:nodeprep(U), LUser = jid:nodeprep(U),
LServer = jlib:nameprep(S), LServer = jid:nameprep(S),
{PeerIP, _} = SIPSock#sip_socket.peer, {PeerIP, _} = SIPSock#sip_socket.peer,
US = {LUser, LServer}, US = {LUser, LServer},
CallID = esip:get_hdr('call-id', Hdrs), CallID = esip:get_hdr('call-id', Hdrs),

View File

@ -261,7 +261,7 @@ set_vcard(User, LServer, VCARD) ->
<<"">> -> EMail2; <<"">> -> EMail2;
_ -> EMail1 _ -> EMail1
end, end,
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LFN = string2lower(FN), LFN = string2lower(FN),
LFamily = string2lower(Family), LFamily = string2lower(Family),
LGiven = string2lower(Given), LGiven = string2lower(Given),
@ -404,7 +404,7 @@ string2lower(String) ->
[{xmlcdata, [{xmlcdata,
<<(translate:translate(Lang, <<(translate:translate(Lang,
<<"Search users in ">>))/binary, <<"Search users in ">>))/binary,
(jlib:jid_to_string(JID))/binary>>}]}, (jid:to_string(JID))/binary>>}]},
#xmlel{name = <<"instructions">>, attrs = [], #xmlel{name = <<"instructions">>, attrs = [],
children = children =
[{xmlcdata, [{xmlcdata,
@ -607,7 +607,7 @@ search_result(Lang, JID, ServerHost, Data) ->
[{xmlcdata, [{xmlcdata,
<<(translate:translate(Lang, <<(translate:translate(Lang,
<<"Search Results for ">>))/binary, <<"Search Results for ">>))/binary,
(jlib:jid_to_string(JID))/binary>>}]}, (jid:to_string(JID))/binary>>}]},
#xmlel{name = <<"reported">>, attrs = [], #xmlel{name = <<"reported">>, attrs = [],
children = children =
[?TLFIELD(<<"text-single">>, <<"Jabber ID">>, [?TLFIELD(<<"text-single">>, <<"Jabber ID">>,
@ -916,8 +916,8 @@ reindex_vcards() ->
mnesia:transaction(F). mnesia:transaction(F).
remove_user(User, Server) -> remove_user(User, Server) ->
LUser = jlib:nodeprep(User), LUser = jid:nodeprep(User),
LServer = jlib:nameprep(Server), LServer = jid:nameprep(Server),
remove_user(LUser, LServer, remove_user(LUser, LServer,
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).

View File

@ -422,7 +422,7 @@ ldap_attribute_to_vcard(_, _) -> none.
[{xmlcdata, [{xmlcdata,
<<(translate:translate(Lang, <<(translate:translate(Lang,
<<"Search users in ">>))/binary, <<"Search users in ">>))/binary,
(jlib:jid_to_string(JID))/binary>>}]}, (jid:to_string(JID))/binary>>}]},
#xmlel{name = <<"instructions">>, attrs = [], #xmlel{name = <<"instructions">>, attrs = [],
children = children =
[{xmlcdata, [{xmlcdata,
@ -600,7 +600,7 @@ search_result(Lang, JID, State, Data) ->
[{xmlcdata, [{xmlcdata,
<<(translate:translate(Lang, <<(translate:translate(Lang,
<<"Search Results for ">>))/binary, <<"Search Results for ">>))/binary,
(jlib:jid_to_string(JID))/binary>>}]}, (jid:to_string(JID))/binary>>}]},
#xmlel{name = <<"reported">>, attrs = [], #xmlel{name = <<"reported">>, attrs = [],
children = children =
[?TLFIELD(<<"text-single">>, <<"Jabber ID">>, [?TLFIELD(<<"text-single">>, <<"Jabber ID">>,

View File

@ -116,7 +116,7 @@ features() ->
%% checked. This parameter depends on the value of the %% checked. This parameter depends on the value of the
%% <tt>access_createnode</tt> ACL value in ejabberd config file.</p> %% <tt>access_createnode</tt> ACL value in ejabberd config file.</p>
create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) -> create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
LOwner = jlib:jid_tolower(Owner), LOwner = jid:tolower(Owner),
Allowed = case LOwner of Allowed = case LOwner of
{<<"">>, Host, <<"">>} -> {<<"">>, Host, <<"">>} ->
true; % pubsub service always allowed true; % pubsub service always allowed
@ -126,7 +126,7 @@ create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
{result, Allowed}. {result, Allowed}.
create_node(Nidx, Owner) -> create_node(Nidx, Owner) ->
OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), OwnerKey = jid:tolower(jid:remove_resource(Owner)),
set_state(#pubsub_state{stateid = {OwnerKey, Nidx}, set_state(#pubsub_state{stateid = {OwnerKey, Nidx},
affiliation = owner}), affiliation = owner}),
{result, {default, broadcast}}. {result, {default, broadcast}}.
@ -178,9 +178,9 @@ delete_node(Nodes) ->
%% <p>In the default plugin module, the record is unchanged.</p> %% <p>In the default plugin module, the record is unchanged.</p>
subscribe_node(Nidx, Sender, Subscriber, AccessModel, subscribe_node(Nidx, Sender, Subscriber, AccessModel,
SendLast, PresenceSubscription, RosterGroup, Options) -> SendLast, PresenceSubscription, RosterGroup, Options) ->
SubKey = jlib:jid_tolower(Subscriber), SubKey = jid:tolower(Subscriber),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
Authorized = jlib:jid_tolower(jlib:jid_remove_resource(Sender)) == GenKey, Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
GenState = get_state(Nidx, GenKey), GenState = get_state(Nidx, GenKey),
SubState = case SubKey of SubState = case SubKey of
GenKey -> GenState; GenKey -> GenState;
@ -238,9 +238,9 @@ subscribe_node(Nidx, Sender, Subscriber, AccessModel,
%% @doc <p>Unsubscribe the <tt>Subscriber</tt> from the <tt>Node</tt>.</p> %% @doc <p>Unsubscribe the <tt>Subscriber</tt> from the <tt>Node</tt>.</p>
unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
SubKey = jlib:jid_tolower(Subscriber), SubKey = jid:tolower(Subscriber),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
Authorized = jlib:jid_tolower(jlib:jid_remove_resource(Sender)) == GenKey, Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
GenState = get_state(Nidx, GenKey), GenState = get_state(Nidx, GenKey),
SubState = case SubKey of SubState = case SubKey of
GenKey -> GenState; GenKey -> GenState;
@ -340,8 +340,8 @@ delete_subscriptions(SubKey, Nidx, Subscriptions, SubState) ->
%% </p> %% </p>
%% <p>In the default plugin module, the record is unchanged.</p> %% <p>In the default plugin module, the record is unchanged.</p>
publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload) -> publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload) ->
SubKey = jlib:jid_tolower(Publisher), SubKey = jid:tolower(Publisher),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
GenState = get_state(Nidx, GenKey), GenState = get_state(Nidx, GenKey),
SubState = case SubKey of SubState = case SubKey of
GenKey -> GenState; GenKey -> GenState;
@ -406,8 +406,8 @@ remove_extra_items(Nidx, MaxItems, ItemIds) ->
%% <p>Default plugin: The user performing the deletion must be the node owner %% <p>Default plugin: The user performing the deletion must be the node owner
%% or a publisher, or PublishModel being open.</p> %% or a publisher, or PublishModel being open.</p>
delete_item(Nidx, Publisher, PublishModel, ItemId) -> delete_item(Nidx, Publisher, PublishModel, ItemId) ->
SubKey = jlib:jid_tolower(Publisher), SubKey = jid:tolower(Publisher),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
GenState = get_state(Nidx, GenKey), GenState = get_state(Nidx, GenKey),
#pubsub_state{affiliation = Affiliation, items = Items} = GenState, #pubsub_state{affiliation = Affiliation, items = Items} = GenState,
Allowed = Affiliation == publisher orelse Allowed = Affiliation == publisher orelse
@ -451,8 +451,8 @@ delete_item(Nidx, Publisher, PublishModel, ItemId) ->
end. end.
purge_node(Nidx, Owner) -> purge_node(Nidx, Owner) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
GenState = get_state(Nidx, GenKey), GenState = get_state(Nidx, GenKey),
case GenState of case GenState of
#pubsub_state{affiliation = owner} -> #pubsub_state{affiliation = owner} ->
@ -478,8 +478,8 @@ purge_node(Nidx, Owner) ->
%% that will be added to the affiliation stored in the main %% that will be added to the affiliation stored in the main
%% <tt>pubsub_state</tt> table.</p> %% <tt>pubsub_state</tt> table.</p>
get_entity_affiliations(Host, Owner) -> get_entity_affiliations(Host, Owner) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
States = mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'}, _ = '_'}), States = mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'}, _ = '_'}),
NodeTree = mod_pubsub:tree(Host), NodeTree = mod_pubsub:tree(Host),
Reply = lists:foldl(fun (#pubsub_state{stateid = {_, N}, affiliation = A}, Acc) -> Reply = lists:foldl(fun (#pubsub_state{stateid = {_, N}, affiliation = A}, Acc) ->
@ -497,14 +497,14 @@ get_node_affiliations(Nidx) ->
{result, lists:map(Tr, States)}. {result, lists:map(Tr, States)}.
get_affiliation(Nidx, Owner) -> get_affiliation(Nidx, Owner) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
#pubsub_state{affiliation = Affiliation} = get_state(Nidx, GenKey), #pubsub_state{affiliation = Affiliation} = get_state(Nidx, GenKey),
{result, Affiliation}. {result, Affiliation}.
set_affiliation(Nidx, Owner, Affiliation) -> set_affiliation(Nidx, Owner, Affiliation) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
GenState = get_state(Nidx, GenKey), GenState = get_state(Nidx, GenKey),
case {Affiliation, GenState#pubsub_state.subscriptions} of case {Affiliation, GenState#pubsub_state.subscriptions} of
{none, []} -> del_state(Nidx, GenKey); {none, []} -> del_state(Nidx, GenKey);
@ -519,8 +519,8 @@ set_affiliation(Nidx, Owner, Affiliation) ->
%% that will be added to the affiliation stored in the main %% that will be added to the affiliation stored in the main
%% <tt>pubsub_state</tt> table.</p> %% <tt>pubsub_state</tt> table.</p>
get_entity_subscriptions(Host, Owner) -> get_entity_subscriptions(Host, Owner) ->
{U, D, _} = SubKey = jlib:jid_tolower(Owner), {U, D, _} = SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
States = case SubKey of States = case SubKey of
GenKey -> GenKey ->
mnesia:match_object(#pubsub_state{stateid = {{U, D, '_'}, '_'}, _ = '_'}); mnesia:match_object(#pubsub_state{stateid = {{U, D, '_'}, '_'}, _ = '_'});
@ -562,12 +562,12 @@ get_node_subscriptions(Nidx) ->
{result, lists:flatmap(Tr, States)}. {result, lists:flatmap(Tr, States)}.
get_subscriptions(Nidx, Owner) -> get_subscriptions(Nidx, Owner) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
SubState = get_state(Nidx, SubKey), SubState = get_state(Nidx, SubKey),
{result, SubState#pubsub_state.subscriptions}. {result, SubState#pubsub_state.subscriptions}.
set_subscriptions(Nidx, Owner, Subscription, SubId) -> set_subscriptions(Nidx, Owner, Subscription, SubId) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
SubState = get_state(Nidx, SubKey), SubState = get_state(Nidx, SubKey),
case {SubId, SubState#pubsub_state.subscriptions} of case {SubId, SubState#pubsub_state.subscriptions} of
{_, []} -> {_, []} ->
@ -620,7 +620,7 @@ unsub_with_subid(Nidx, SubId, #pubsub_state{stateid = {Entity, _}} = SubState) -
%% @doc <p>Returns a list of Owner's nodes on Host with pending %% @doc <p>Returns a list of Owner's nodes on Host with pending
%% subscriptions.</p> %% subscriptions.</p>
get_pending_nodes(Host, Owner) -> get_pending_nodes(Host, Owner) ->
GenKey = jlib:jid_remove_resource(jlib:jid_tolower(Owner)), GenKey = jid:remove_resource(jid:tolower(Owner)),
States = mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'}, States = mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'},
affiliation = owner, affiliation = owner,
_ = '_'}), _ = '_'}),
@ -702,8 +702,8 @@ get_items(Nidx, _From, _RSM) ->
{result, {lists:reverse(lists:keysort(#pubsub_item.modification, Items)), none}}. {result, {lists:reverse(lists:keysort(#pubsub_item.modification, Items)), none}}.
get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM) -> get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM) ->
SubKey = jlib:jid_tolower(JID), SubKey = jid:tolower(JID),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
GenState = get_state(Nidx, GenKey), GenState = get_state(Nidx, GenKey),
SubState = get_state(Nidx, SubKey), SubState = get_state(Nidx, SubKey),
Affiliation = GenState#pubsub_state.affiliation, Affiliation = GenState#pubsub_state.affiliation,
@ -746,8 +746,8 @@ get_item(Nidx, ItemId) ->
end. end.
get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId) -> get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId) ->
SubKey = jlib:jid_tolower(JID), SubKey = jid:tolower(JID),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
GenState = get_state(Nidx, GenKey), GenState = get_state(Nidx, GenKey),
Affiliation = GenState#pubsub_state.affiliation, Affiliation = GenState#pubsub_state.affiliation,
Subscriptions = GenState#pubsub_state.subscriptions, Subscriptions = GenState#pubsub_state.subscriptions,

View File

@ -73,7 +73,7 @@ create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_flat:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access). node_flat:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
create_node(Nidx, Owner) -> create_node(Nidx, Owner) ->
{_U, _S, _R} = OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), {_U, _S, _R} = OwnerKey = jid:tolower(jid:remove_resource(Owner)),
State = #pubsub_state{stateid = {OwnerKey, Nidx}, affiliation = owner}, State = #pubsub_state{stateid = {OwnerKey, Nidx}, affiliation = owner},
catch ejabberd_odbc:sql_query_t([<<"insert into pubsub_state(nodeid, jid, affiliation, subscriptions) " catch ejabberd_odbc:sql_query_t([<<"insert into pubsub_state(nodeid, jid, affiliation, subscriptions) "
"values(">>, state_to_raw(Nidx, State), <<");">>]), "values(">>, state_to_raw(Nidx, State), <<");">>]),
@ -96,9 +96,9 @@ delete_node(Nodes) ->
subscribe_node(Nidx, Sender, Subscriber, AccessModel, subscribe_node(Nidx, Sender, Subscriber, AccessModel,
SendLast, PresenceSubscription, RosterGroup, Options) -> SendLast, PresenceSubscription, RosterGroup, Options) ->
SubKey = jlib:jid_tolower(Subscriber), SubKey = jid:tolower(Subscriber),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
Authorized = jlib:jid_tolower(jlib:jid_remove_resource(Sender)) == GenKey, Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
{Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey, SubKey), {Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey, SubKey),
Whitelisted = lists:member(Affiliation, [member, publisher, owner]), Whitelisted = lists:member(Affiliation, [member, publisher, owner]),
PendingSubscription = lists:any(fun PendingSubscription = lists:any(fun
@ -145,9 +145,9 @@ subscribe_node(Nidx, Sender, Subscriber, AccessModel,
end. end.
unsubscribe_node(Nidx, Sender, Subscriber, SubId) -> unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
SubKey = jlib:jid_tolower(Subscriber), SubKey = jid:tolower(Subscriber),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
Authorized = jlib:jid_tolower(jlib:jid_remove_resource(Sender)) == GenKey, Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
{Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, SubKey), {Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, SubKey),
SubIdExists = case SubId of SubIdExists = case SubId of
<<>> -> false; <<>> -> false;
@ -207,8 +207,8 @@ delete_subscription(SubKey, Nidx, {Subscription, SubId}, Affiliation, Subscripti
end. end.
publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload) -> publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload) ->
SubKey = jlib:jid_tolower(Publisher), SubKey = jid:tolower(Publisher),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
{Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey, SubKey), {Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey, SubKey),
Subscribed = case PublishModel of Subscribed = case PublishModel of
subscribers -> node_flat:is_subscribed(Subscriptions); subscribers -> node_flat:is_subscribed(Subscriptions);
@ -245,8 +245,8 @@ remove_extra_items(Nidx, MaxItems, ItemIds) ->
{result, {NewItems, OldItems}}. {result, {NewItems, OldItems}}.
delete_item(Nidx, Publisher, PublishModel, ItemId) -> delete_item(Nidx, Publisher, PublishModel, ItemId) ->
SubKey = jlib:jid_tolower(Publisher), SubKey = jid:tolower(Publisher),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
{result, Affiliation} = get_affiliation(Nidx, GenKey), {result, Affiliation} = get_affiliation(Nidx, GenKey),
Allowed = Affiliation == publisher orelse Allowed = Affiliation == publisher orelse
Affiliation == owner orelse Affiliation == owner orelse
@ -265,8 +265,8 @@ delete_item(Nidx, Publisher, PublishModel, ItemId) ->
end. end.
purge_node(Nidx, Owner) -> purge_node(Nidx, Owner) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
GenState = get_state(Nidx, GenKey), GenState = get_state(Nidx, GenKey),
case GenState of case GenState of
#pubsub_state{affiliation = owner} -> #pubsub_state{affiliation = owner} ->
@ -282,8 +282,8 @@ purge_node(Nidx, Owner) ->
end. end.
get_entity_affiliations(Host, Owner) -> get_entity_affiliations(Host, Owner) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
H = encode_host(Host), H = encode_host(Host),
J = encode_jid(GenKey), J = encode_jid(GenKey),
Reply = case catch Reply = case catch
@ -312,8 +312,8 @@ get_node_affiliations(Nidx) ->
{result, Reply}. {result, Reply}.
get_affiliation(Nidx, Owner) -> get_affiliation(Nidx, Owner) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
J = encode_jid(GenKey), J = encode_jid(GenKey),
Reply = case catch Reply = case catch
ejabberd_odbc:sql_query_t([<<"select affiliation from pubsub_state " ejabberd_odbc:sql_query_t([<<"select affiliation from pubsub_state "
@ -327,8 +327,8 @@ get_affiliation(Nidx, Owner) ->
{result, Reply}. {result, Reply}.
set_affiliation(Nidx, Owner, Affiliation) -> set_affiliation(Nidx, Owner, Affiliation) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
{_, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey), {_, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey),
case {Affiliation, Subscriptions} of case {Affiliation, Subscriptions} of
{none, []} -> del_state(Nidx, GenKey); {none, []} -> del_state(Nidx, GenKey);
@ -336,8 +336,8 @@ set_affiliation(Nidx, Owner, Affiliation) ->
end. end.
get_entity_subscriptions(Host, Owner) -> get_entity_subscriptions(Host, Owner) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
H = encode_host(Host), H = encode_host(Host),
SJ = encode_jid(SubKey), SJ = encode_jid(SubKey),
GJ = encode_jid(GenKey), GJ = encode_jid(GenKey),
@ -385,8 +385,8 @@ get_entity_subscriptions(Host, Owner) ->
} }
). ).
get_entity_subscriptions_for_send_last(Host, Owner) -> get_entity_subscriptions_for_send_last(Host, Owner) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
H = encode_host(Host), H = encode_host(Host),
SJ = encode_jid(SubKey), SJ = encode_jid(SubKey),
GJ = encode_jid(GenKey), GJ = encode_jid(GenKey),
@ -449,7 +449,7 @@ get_node_subscriptions(Nidx) ->
{result, Reply}. {result, Reply}.
get_subscriptions(Nidx, Owner) -> get_subscriptions(Nidx, Owner) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
J = encode_jid(SubKey), J = encode_jid(SubKey),
Reply = case catch Reply = case catch
ejabberd_odbc:sql_query_t([<<"select subscriptions from pubsub_state where " ejabberd_odbc:sql_query_t([<<"select subscriptions from pubsub_state where "
@ -463,7 +463,7 @@ get_subscriptions(Nidx, Owner) ->
{result, Reply}. {result, Reply}.
set_subscriptions(Nidx, Owner, Subscription, SubId) -> set_subscriptions(Nidx, Owner, Subscription, SubId) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
SubState = get_state_without_itemids(Nidx, SubKey), SubState = get_state_without_itemids(Nidx, SubKey),
case {SubId, SubState#pubsub_state.subscriptions} of case {SubId, SubState#pubsub_state.subscriptions} of
{_, []} -> {_, []} ->
@ -514,7 +514,7 @@ unsub_with_subid(Nidx, SubId, SubState) ->
end. end.
get_pending_nodes(Host, Owner) -> get_pending_nodes(Host, Owner) ->
GenKey = jlib:jid_remove_resource(jlib:jid_tolower(Owner)), GenKey = jid:remove_resource(jid:tolower(Owner)),
States = mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'}, States = mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'},
affiliation = owner, _ = '_'}), affiliation = owner, _ = '_'}),
Nidxxs = [Nidx || #pubsub_state{stateid = {_, Nidx}} <- States], Nidxxs = [Nidx || #pubsub_state{stateid = {_, Nidx}} <- States],
@ -719,8 +719,8 @@ get_items(Nidx, _From,
end. end.
get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM) -> get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, RSM) ->
SubKey = jlib:jid_tolower(JID), SubKey = jid:tolower(JID),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
{Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey, SubKey), {Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey, SubKey),
Whitelisted = node_flat:can_fetch_item(Affiliation, Subscriptions), Whitelisted = node_flat:can_fetch_item(Affiliation, Subscriptions),
if %%SubId == "", ?? -> if %%SubId == "", ?? ->
@ -777,8 +777,8 @@ get_item(Nidx, ItemId) ->
end. end.
get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId) -> get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId) ->
SubKey = jlib:jid_tolower(JID), SubKey = jid:tolower(JID),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
{Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey, SubKey), {Affiliation, Subscriptions} = select_affiliation_subscriptions(Nidx, GenKey, SubKey),
Whitelisted = node_flat:can_fetch_item(Affiliation, Subscriptions), Whitelisted = node_flat:can_fetch_item(Affiliation, Subscriptions),
if %%SubId == "", ?? -> if %%SubId == "", ?? ->
@ -939,7 +939,7 @@ update_subscription(Nidx, JID, Subscription) ->
-> ljid() -> ljid()
). ).
decode_jid(SJID) -> decode_jid(SJID) ->
jlib:jid_tolower(jlib:string_to_jid(SJID)). jid:tolower(jid:from_string(SJID)).
-spec(decode_affiliation/1 :: -spec(decode_affiliation/1 ::
( Arg :: binary()) ( Arg :: binary())
@ -979,7 +979,7 @@ decode_subscriptions(Subscriptions) ->
-> binary() -> binary()
). ).
encode_jid(JID) -> encode_jid(JID) ->
ejabberd_odbc:escape(jlib:jid_to_string(JID)). ejabberd_odbc:escape(jid:to_string(JID)).
-spec(encode_host/1 :: -spec(encode_host/1 ::
( Host :: host()) ( Host :: host())

View File

@ -69,7 +69,7 @@ features() ->
%% <p>This function also check that node can be created as a children of its %% <p>This function also check that node can be created as a children of its
%% parent node</p> %% parent node</p>
create_node_permission(Host, ServerHost, Node, _ParentNode, Owner, Access) -> create_node_permission(Host, ServerHost, Node, _ParentNode, Owner, Access) ->
LOwner = jlib:jid_tolower(Owner), LOwner = jid:tolower(Owner),
{User, Server, _Resource} = LOwner, {User, Server, _Resource} = LOwner,
Allowed = case LOwner of Allowed = case LOwner of
{<<"">>, Host, <<"">>} -> {<<"">>, Host, <<"">>} ->

View File

@ -94,7 +94,7 @@ features() ->
<<"subscribe">>]. <<"subscribe">>].
create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) -> create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
LOwner = jlib:jid_tolower(Owner), LOwner = jid:tolower(Owner),
{User, Server, _Resource} = LOwner, {User, Server, _Resource} = LOwner,
Allowed = case LOwner of Allowed = case LOwner of
{<<"">>, Host, <<"">>} -> {<<"">>, Host, <<"">>} ->
@ -143,9 +143,9 @@ purge_node(Nidx, Owner) ->
node_flat:purge_node(Nidx, Owner). node_flat:purge_node(Nidx, Owner).
get_entity_affiliations(Host, Owner) -> get_entity_affiliations(Host, Owner) ->
{_, D, _} = SubKey = jlib:jid_tolower(Owner), {_, D, _} = SubKey = jid:tolower(Owner),
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
States = mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'}, _ = '_'}), States = mnesia:match_object(#pubsub_state{stateid = {GenKey, '_'}, _ = '_'}),
NodeTree = mod_pubsub:tree(Host), NodeTree = mod_pubsub:tree(Host),
Reply = lists:foldl(fun (#pubsub_state{stateid = {_, N}, affiliation = A}, Acc) -> Reply = lists:foldl(fun (#pubsub_state{stateid = {_, N}, affiliation = A}, Acc) ->
@ -168,8 +168,8 @@ set_affiliation(Nidx, Owner, Affiliation) ->
node_flat:set_affiliation(Nidx, Owner, Affiliation). node_flat:set_affiliation(Nidx, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) -> get_entity_subscriptions(Host, Owner) ->
{U, D, _} = SubKey = jlib:jid_tolower(Owner), {U, D, _} = SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
States = case SubKey of States = case SubKey of
GenKey -> GenKey ->
mnesia:match_object(#pubsub_state{stateid = {{U, D, '_'}, '_'}, _ = '_'}); mnesia:match_object(#pubsub_state{stateid = {{U, D, '_'}, '_'}, _ = '_'});

View File

@ -100,7 +100,7 @@ purge_node(Nidx, Owner) ->
node_flat_odbc:purge_node(Nidx, Owner). node_flat_odbc:purge_node(Nidx, Owner).
get_entity_affiliations(_Host, Owner) -> get_entity_affiliations(_Host, Owner) ->
OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), OwnerKey = jid:tolower(jid:remove_resource(Owner)),
node_flat_odbc:get_entity_affiliations(OwnerKey, Owner). node_flat_odbc:get_entity_affiliations(OwnerKey, Owner).
get_node_affiliations(Nidx) -> get_node_affiliations(Nidx) ->
@ -113,8 +113,8 @@ set_affiliation(Nidx, Owner, Affiliation) ->
node_flat_odbc:set_affiliation(Nidx, Owner, Affiliation). node_flat_odbc:set_affiliation(Nidx, Owner, Affiliation).
get_entity_subscriptions(_Host, Owner) -> get_entity_subscriptions(_Host, Owner) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
Host = node_flat_odbc:encode_host(element(2, SubKey)), Host = node_flat_odbc:encode_host(element(2, SubKey)),
SJ = node_flat_odbc:encode_jid(SubKey), SJ = node_flat_odbc:encode_jid(SubKey),
GJ = node_flat_odbc:encode_jid(GenKey), GJ = node_flat_odbc:encode_jid(GenKey),
@ -148,8 +148,8 @@ get_entity_subscriptions(_Host, Owner) ->
{result, Reply}. {result, Reply}.
get_entity_subscriptions_for_send_last(_Host, Owner) -> get_entity_subscriptions_for_send_last(_Host, Owner) ->
SubKey = jlib:jid_tolower(Owner), SubKey = jid:tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey), GenKey = jid:remove_resource(SubKey),
Host = node_flat_odbc:encode_host(element(2, SubKey)), Host = node_flat_odbc:encode_host(element(2, SubKey)),
SJ = node_flat_odbc:encode_jid(SubKey), SJ = node_flat_odbc:encode_jid(SubKey),
GJ = node_flat_odbc:encode_jid(GenKey), GJ = node_flat_odbc:encode_jid(GenKey),

View File

@ -51,7 +51,7 @@ set_node(#pubsub_node{nodeid = {Key, _}, owners = Owners, options = Options} = N
end. end.
create_node(Key, Node, Type, Owner, Options, Parents) -> create_node(Key, Node, Type, Owner, Options, Parents) ->
OwnerJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), OwnerJID = jid:tolower(jid:remove_resource(Owner)),
case find_node(Key, Node) of case find_node(Key, Node) of
false -> false ->
Nidx = pubsub_index:new(node), Nidx = pubsub_index:new(node),

View File

@ -148,7 +148,7 @@ get_subnodes_tree(Host, Node) ->
end. end.
create_node(Host, Node, Type, Owner, Options, Parents) -> create_node(Host, Node, Type, Owner, Options, Parents) ->
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), BJID = jid:tolower(jid:remove_resource(Owner)),
case catch mnesia:read({pubsub_node, {Host, Node}}) of case catch mnesia:read({pubsub_node, {Host, Node}}) of
[] -> [] ->
ParentExists = case Host of ParentExists = case Host of

View File

@ -211,7 +211,7 @@ get_subnodes_tree(Host, Node) ->
end. end.
create_node(Host, Node, Type, Owner, Options, Parents) -> create_node(Host, Node, Type, Owner, Options, Parents) ->
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)), BJID = jid:tolower(jid:remove_resource(Owner)),
case nodeidx(Host, Node) of case nodeidx(Host, Node) of
{error, ?ERR_ITEM_NOT_FOUND} -> {error, ?ERR_ITEM_NOT_FOUND} ->
ParentExists = case Host of ParentExists = case Host of

View File

@ -36,7 +36,7 @@
-spec salted_password(binary(), binary(), non_neg_integer()) -> binary(). -spec salted_password(binary(), binary(), non_neg_integer()) -> binary().
salted_password(Password, Salt, IterationCount) -> salted_password(Password, Salt, IterationCount) ->
hi(jlib:resourceprep(Password), Salt, IterationCount). hi(jid:resourceprep(Password), Salt, IterationCount).
-spec client_key(binary()) -> binary(). -spec client_key(binary()) -> binary().