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

Update to use the new names used in exmpp_jid.

SVN Revision: 1515
This commit is contained in:
Jean-Sébastien Pédron 2008-08-06 13:51:42 +00:00
parent cb20c9b0d7
commit 85c2097ece
13 changed files with 60 additions and 54 deletions

View File

@ -8,6 +8,12 @@
src/mod_disco.erl, src/mod_caps.erl: Update to use the new
exmpp_xml:get_attribute/{3,4} API.
* src/ejabberd_c2s.erl, src/ejabberd_s2s_in.erl,
src/ejabberd_s2s_out.erl, src/ejabberd_service.erl, src/mod_adhoc.erl,
src/mod_caps.erl, src/mod_configure.erl, src/mod_disco.erl,
src/mod_echo.erl, src/mod_offline.erl, src/mod_roster.erl,
src/mod_vcard.erl: Update to use the new names used in exmpp_jid.
2008-07-25 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/adhoc.erl, src/mod_configure.erl, src/mod_announce.erl,

View File

@ -398,7 +398,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
?INFO_MSG(
"(~w) Accepted legacy authentication for ~s",
[StateData#state.socket,
exmpp_jid:jid_to_string(JID)]),
exmpp_jid:jid_to_list(JID)]),
SID = {now(), self()},
Conn = get_conn_type(StateData),
Info = [{ip, StateData#state.ip}, {conn, Conn},
@ -435,7 +435,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
?INFO_MSG(
"(~w) Failed legacy authentication for ~s",
[StateData#state.socket,
exmpp_jid:jid_to_string(JID)]),
exmpp_jid:jid_to_list(JID)]),
Res = exmpp_iq:error_without_original(El,
'not-authorized'),
send_element(StateData, Res),
@ -445,7 +445,7 @@ wait_for_auth({xmlstreamelement, El}, StateData) ->
?INFO_MSG(
"(~w) Forbidden legacy authentication for ~s",
[StateData#state.socket,
exmpp_jid:jid_to_string(JID)]),
exmpp_jid:jid_to_list(JID)]),
Res = exmpp_iq:error_without_original(El,
'not-allowed'),
send_element(StateData, Res),
@ -713,7 +713,7 @@ wait_for_session({xmlstreamelement, El}, StateData) ->
allow ->
?INFO_MSG("(~w) Opened session for ~s",
[StateData#state.socket,
exmpp_jid:jid_to_string(JID)]),
exmpp_jid:jid_to_list(JID)]),
SID = {now(), self()},
Conn = get_conn_type(StateData),
Info = [{ip, StateData#state.ip}, {conn, Conn},
@ -750,7 +750,7 @@ wait_for_session({xmlstreamelement, El}, StateData) ->
StateData#state.server, [JIDOld]),
?INFO_MSG("(~w) Forbidden session for ~s",
[StateData#state.socket,
exmpp_jid:jid_to_string(JID)]),
exmpp_jid:jid_to_list(JID)]),
Err = exmpp_server_session:error(El, 'not-allowed'),
send_element(StateData, Err),
fsm_next_state(wait_for_session, StateData)
@ -787,7 +787,7 @@ session_established({xmlstreamelement, El}, StateData) ->
undefined ->
exmpp_jid:make_bare_jid(User, Server);
_ ->
exmpp_jid:string_to_jid(To)
exmpp_jid:list_to_jid(To)
end,
NewEl = case exmpp_stanza:get_lang(El) of
undefined ->
@ -1237,7 +1237,7 @@ terminate(_Reason, StateName, StateData) ->
replaced ->
?INFO_MSG("(~w) Replaced session for ~s",
[StateData#state.socket,
exmpp_jid:jid_to_string(StateData#state.jid)]),
exmpp_jid:jid_to_list(StateData#state.jid)]),
From = StateData#state.jid,
Packet = exmpp_presence:unavailable(),
Packet1 = exmpp_presence:set_status(Packet,
@ -1255,7 +1255,7 @@ terminate(_Reason, StateName, StateData) ->
_ ->
?INFO_MSG("(~w) Close session for ~s",
[StateData#state.socket,
exmpp_jid:jid_to_string(StateData#state.jid)]),
exmpp_jid:jid_to_list(StateData#state.jid)]),
EmptySet = ?SETS:new(),
case StateData of

View File

@ -371,7 +371,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
error;
F ->
try
exmpp_jid:string_to_jid(F)
exmpp_jid:list_to_jid(F)
catch
_Exception1 -> error
end
@ -381,7 +381,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
error;
T ->
try
exmpp_jid:string_to_jid(T)
exmpp_jid:list_to_jid(T)
catch
_Exception2 -> error
end
@ -621,7 +621,7 @@ get_cert_domains(Cert) ->
end,
if
D /= error ->
case exmpp_jid:string_to_jid(D) of
case exmpp_jid:list_to_jid(D) of
#jid{lnode = undefined,
ldomain = LD,
lresource = undefined} ->
@ -674,7 +674,7 @@ get_cert_domains(Cert) ->
[]
end;
({dNSName, D}) when is_list(D) ->
case exmpp_jid:string_to_jid(D) of
case exmpp_jid:list_to_jid(D) of
#jid{lnode = undefined,
ldomain = LD,
lresource = undefined} ->

View File

@ -809,8 +809,8 @@ bounce_element(El, Condition) ->
"result" -> ok;
_ ->
Err = exmpp_stanza:reply_with_error(El, Condition),
From = exmpp_jid:string_to_jid(exmpp_stanza:get_sender(El)),
To = exmpp_jid:string_to_jid(exmpp_stanza:get_recipient(El)),
From = exmpp_jid:list_to_jid(exmpp_stanza:get_sender(El)),
To = exmpp_jid:list_to_jid(exmpp_stanza:get_recipient(El)),
% No namespace conversion (:server <-> :client) is done.
% This is handled by C2S and S2S send_element functions.
ejabberd_router:route(To, From, Err)

View File

@ -223,7 +223,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
%% when accept packets from any address.
%% In this case, the component can send packet of
%% behalf of the server users.
false -> exmpp_jid:string_to_jid(From);
false -> exmpp_jid:list_to_jid(From);
%% The default is the standard behaviour in XEP-0114
_ ->
FromJID1 = exmpp_jib:string_to_jid(From),

View File

@ -124,7 +124,7 @@ get_sm_commands(Acc, _From, #jid{ldomain = LServer} = To, "", Lang) ->
end,
Nodes = [#xmlel{ns = ?NS_DISCO_ITEMS,
name = 'item', attrs =
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_string(To)},
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(To)},
#xmlattr{name = 'node', value = ?NS_ADHOC_s},
#xmlattr{name = 'name', value = translate:translate(Lang, "Commands")}]
}],

View File

@ -254,9 +254,9 @@ handle_cast({disco_response, From, _To, IQ},
?ERROR_MSG("ID '~s' matches no query", [ID])
end;
%gen_server:cast(self(), visit_feature_queries),
%?DEBUG("Error IQ reponse from ~s:~n~p", [exmpp_jid:jid_to_string(From), SubEls]);
%?DEBUG("Error IQ reponse from ~s:~n~p", [exmpp_jid:jid_to_list(From), SubEls]);
{result, _} ->
?DEBUG("Invalid IQ contents from ~s:~n~p", [exmpp_jid:jid_to_string(From), IQ#xmlel.children]);
?DEBUG("Invalid IQ contents from ~s:~n~p", [exmpp_jid:jid_to_list(From), IQ#xmlel.children]);
_ ->
%% Can't do anything about errors
ok

View File

@ -98,7 +98,7 @@ stop(Host) ->
-define(NODEJID(To, Name, Node),
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_string(To)},
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(To)},
#xmlattr{name = 'name', value = ?T(Lang, Name)},
#xmlattr{name = 'node', value = Node}]}).
@ -258,7 +258,7 @@ adhoc_sm_items(Acc, From, #jid{ldomain = LServer} = To, Lang) ->
empty -> []
end,
Nodes = [#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_string(To)},
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(To)},
#xmlattr{name = 'name', value = ?T(Lang, "Configuration")},
#xmlattr{name = 'node', value = "config"}]}],
{result, Items ++ Nodes};
@ -297,7 +297,7 @@ get_user_resources(User, Server) ->
Rs = ejabberd_sm:get_user_resources(User, Server),
lists:map(fun(R) ->
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_string(User, Server, R)},
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(User, Server, R)},
#xmlattr{name = 'name', value = User}]}
end, lists:sort(Rs)).
@ -365,7 +365,7 @@ recursively_get_local_items(LServer, Node, Server, Lang) ->
Fallback;
allow ->
case get_local_items(LServer, LNode,
exmpp_jid:jid_to_string(To), Lang) of
exmpp_jid:jid_to_list(To), Lang) of
{result, Res} ->
{result, Res};
{error, Error} ->
@ -388,7 +388,7 @@ get_local_items(Acc, From, #jid{ldomain = LServer} = To, "", Lang) ->
{result, Items};
allow ->
case get_local_items(LServer, [],
exmpp_jid:jid_to_string(To), Lang) of
exmpp_jid:jid_to_list(To), Lang) of
{result, Res} ->
{result, Items ++ Res};
{error, _Error} ->
@ -507,8 +507,8 @@ get_local_items(Host, ["all users", [$@ | Diap]], _Server, _Lang) ->
Sub = lists:sublist(SUsers, N1, N2 - N1 + 1),
lists:map(fun({S, U}) ->
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_string(U, S)},
#xmlattr{name = 'name', value = exmpp_jid:jid_to_string(U, S)}]}
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(U, S)},
#xmlattr{name = 'name', value = exmpp_jid:jid_to_list(U, S)}]}
end, Sub)
end of
{'EXIT', _Reason} ->
@ -591,8 +591,8 @@ get_online_vh_users(Host) ->
SURs = lists:sort([{S, U, R} || {U, S, R} <- USRs]),
lists:map(fun({S, U, R}) ->
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_string(U, S, R)},
#xmlattr{name = 'name', value = exmpp_jid:jid_to_string(U, S)}]}
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(U, S, R)},
#xmlattr{name = 'name', value = exmpp_jid:jid_to_list(U, S)}]}
end, SURs)
end.
@ -606,8 +606,8 @@ get_all_vh_users(Host) ->
N when N =< 100 ->
lists:map(fun({S, U}) ->
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs =
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_string(U, S)},
#xmlattr{name = 'name', value = exmpp_jid:jid_to_string(U, S)}]}
[#xmlattr{name = 'jid', value = exmpp_jid:jid_to_list(U, S)},
#xmlattr{name = 'name', value = exmpp_jid:jid_to_list(U, S)}]}
end, SUsers);
N ->
NParts = trunc(math:sqrt(N * 0.618)) + 1,
@ -1534,7 +1534,7 @@ set_form(_From, _Host, ?NS_ADMINL("add-user"), _Lang, XData) ->
AccountString = get_value("accountjid", XData),
Password = get_value("password", XData),
Password = get_value("password-verify", XData),
AccountJID = exmpp_jid:string_to_jid(AccountString),
AccountJID = exmpp_jid:list_to_jid(AccountString),
User = AccountJID#jid.lnode,
Server = AccountJID#jid.ldomain,
true = lists:member(Server, ?MYHOSTS),
@ -1546,7 +1546,7 @@ set_form(_From, _Host, ?NS_ADMINL("delete-user"), _Lang, XData) ->
[_|_] = AccountStringList,
ASL2 = lists:map(
fun(AccountString) ->
JID = exmpp_jid:string_to_jid(AccountString),
JID = exmpp_jid:list_to_jid(AccountString),
[_|_] = JID#jid.lnode,
User = JID#jid.lnode,
Server = JID#jid.ldomain,
@ -1559,7 +1559,7 @@ set_form(_From, _Host, ?NS_ADMINL("delete-user"), _Lang, XData) ->
set_form(_From, _Host, ?NS_ADMINL("end-user-session"), _Lang, XData) ->
AccountString = get_value("accountjid", XData),
JID = exmpp_jid:string_to_jid(AccountString),
JID = exmpp_jid:list_to_jid(AccountString),
[_|_] = JID#jid.lnode,
LUser = JID#jid.lnode,
LServer = JID#jid.ldomain,
@ -1578,7 +1578,7 @@ set_form(_From, _Host, ?NS_ADMINL("end-user-session"), _Lang, XData) ->
set_form(_From, _Host, ?NS_ADMINL("get-user-password"), Lang, XData) ->
AccountString = get_value("accountjid", XData),
JID = exmpp_jid:string_to_jid(AccountString),
JID = exmpp_jid:list_to_jid(AccountString),
[_|_] = JID#jid.lnode,
User = JID#jid.lnode,
Server = JID#jid.ldomain,
@ -1593,7 +1593,7 @@ set_form(_From, _Host, ?NS_ADMINL("get-user-password"), Lang, XData) ->
set_form(_From, _Host, ?NS_ADMINL("change-user-password"), _Lang, XData) ->
AccountString = get_value("accountjid", XData),
Password = get_value("password", XData),
JID = exmpp_jid:string_to_jid(AccountString),
JID = exmpp_jid:list_to_jid(AccountString),
[_|_] = JID#jid.lnode,
User = JID#jid.lnode,
Server = JID#jid.ldomain,
@ -1603,7 +1603,7 @@ set_form(_From, _Host, ?NS_ADMINL("change-user-password"), _Lang, XData) ->
set_form(_From, _Host, ?NS_ADMINL("get-user-lastlogin"), Lang, XData) ->
AccountString = get_value("accountjid", XData),
JID = exmpp_jid:string_to_jid(AccountString),
JID = exmpp_jid:list_to_jid(AccountString),
[_|_] = JID#jid.lnode,
User = JID#jid.lnode,
Server = JID#jid.ldomain,
@ -1640,7 +1640,7 @@ set_form(_From, _Host, ?NS_ADMINL("get-user-lastlogin"), Lang, XData) ->
set_form(_From, _Host, ?NS_ADMINL("user-stats"), Lang, XData) ->
AccountString = get_value("accountjid", XData),
JID = exmpp_jid:string_to_jid(AccountString),
JID = exmpp_jid:list_to_jid(AccountString),
[_|_] = JID#jid.lnode,
User = JID#jid.lnode,
Server = JID#jid.ldomain,

View File

@ -418,7 +418,7 @@ get_user_resources(User, Server) ->
lists:map(fun(R) ->
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [
#xmlattr{name = 'jid', value =
exmpp_jid:jid_to_string(User, Server, R)},
exmpp_jid:jid_to_list(User, Server, R)},
#xmlattr{name = 'name', value = User}
]}
end, lists:sort(Rs)).

View File

@ -200,5 +200,5 @@ do_client_version(enabled, From, To) ->
%% Print in log
Values_string1 = [io_lib:format("~n~s: ~p", [N, V]) || {N, V} <- Values],
Values_string2 = lists:concat(Values_string1),
?INFO_MSG("Information of the client: ~s~s", [exmpp_jid:jid_to_string(To), Values_string2]).
?INFO_MSG("Information of the client: ~s~s", [exmpp_jid:jid_to_list(To), Values_string2]).

View File

@ -497,8 +497,8 @@ user_queue(User, Server, Query, Lang) ->
io_lib:format(
"~w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
[Year, Month, Day, Hour, Minute, Second])),
SFrom = exmpp_jid:jid_to_string(jlib:from_old_jid(From)),
STo = exmpp_jid:jid_to_string(jlib:from_old_jid(To)),
SFrom = exmpp_jid:jid_to_list(jlib:from_old_jid(From)),
STo = exmpp_jid:jid_to_list(jlib:from_old_jid(To)),
Packet0 = exmpp_xml:xmlelement_to_xmlel(Packet,
[?DEFAULT_NS], ?PREFIXED_NS),
Packet1 = exmpp_stanza:set_jids(Packet0, SFrom, STo),
@ -568,7 +568,7 @@ user_queue_parse_query(US, Query) ->
end.
us_to_list({User, Server}) ->
exmpp_jid:jid_to_string(User, Server).
exmpp_jid:jid_to_list(User, Server).
webadmin_user(Acc, User, Server, Lang) ->
US = {exmpp_stringprep:nodeprep(User), exmpp_stringprep:nameprep(Server)},

View File

@ -156,7 +156,7 @@ get_user_roster(Acc, US) ->
item_to_xml(Item) ->
{U, S, R} = Item#roster.jid,
Attrs1 = exmpp_xml:set_attribute_in_list([],
'jid', exmpp_jid:jid_to_string(U, S, R)),
'jid', exmpp_jid:jid_to_list(U, S, R)),
Attrs2 = case Item#roster.name of
"" ->
Attrs1;
@ -194,7 +194,7 @@ process_iq_set(From, To, IQ) ->
process_item_set(From, To, #xmlel{} = Item) ->
try
JID1 = exmpp_jid:string_to_jid(exmpp_xml:get_attribute(Item, 'jid', "")),
JID1 = exmpp_jid:list_to_jid(exmpp_xml:get_attribute(Item, 'jid', "")),
% XXX OLD FORMAT: old JID (with empty strings).
#jid{node = User, lnode = LUser, ldomain = LServer} =
jlib:to_old_jid(From),
@ -276,7 +276,7 @@ process_item_attrs(Item, [#xmlattr{name = Attr, value = Val} | Attrs]) ->
case Attr of
'jid' ->
try
JID1 = exmpp_jid:string_to_jid(Val),
JID1 = exmpp_jid:list_to_jid(Val),
JID = {JID1#jid.node, JID1#jid.domain, JID1#jid.resource},
process_item_attrs(Item#roster{jid = JID}, Attrs)
catch
@ -587,7 +587,7 @@ set_items(User, Server, SubEl) ->
process_item_set_t(LUser, LServer, #xmlel{} = El) ->
try
JID1 = exmpp_jid:string_to_jid(exmpp_xml:get_attribute(El, 'jid', "")),
JID1 = exmpp_jid:list_to_jid(exmpp_xml:get_attribute(El, 'jid', "")),
JID = {JID1#jid.node, JID1#jid.domain, JID1#jid.resource},
LJID = {JID1#jid.lnode, JID1#jid.ldomain, JID1#jid.lresource},
Item = #roster{usj = {LUser, LServer, LJID},
@ -612,7 +612,7 @@ process_item_attrs_ws(Item, [#xmlattr{name = Attr, value = Val} | Attrs]) ->
case Attr of
'jid' ->
try
JID1 = exmpp_jid:string_to_jid(Val),
JID1 = exmpp_jid:list_to_jid(Val),
JID = {JID1#jid.node, JID1#jid.domain, JID1#jid.resource},
process_item_attrs_ws(Item#roster{jid = JID}, Attrs)
catch
@ -664,9 +664,9 @@ get_in_pending_subscriptions(Ls, User, Server) ->
end,
{U, S, R} = R#roster.jid,
Attrs1 = exmpp_stanza:set_sender_in_list([],
exmpp_jid:jid_to_string(U, S, R)),
exmpp_jid:jid_to_list(U, S, R)),
Attrs2 = exmpp_stanza:set_recipient_in_list(Attrs1,
exmpp_jid:jid_to_string(JID)),
exmpp_jid:jid_to_list(JID)),
Pres1 = exmpp_presence:subscribe(),
Pres2 = Pres1#xmlel{attrs = Attrs2},
exmpp_presence:set_status(Pres2, Status)
@ -815,7 +815,7 @@ user_roster(User, Server, Query, Lang) ->
{U, S, R} = R#roster.jid,
?XE("tr",
[?XAC("td", [{"class", "valign"}],
catch exmpp_jid:jid_to_string(U, S, R)),
catch exmpp_jid:jid_to_list(U, S, R)),
?XAC("td", [{"class", "valign"}],
R#roster.name),
?XAC("td", [{"class", "valign"}],
@ -861,7 +861,7 @@ user_roster_parse_query(User, Server, Items, Query) ->
error;
{value, {_, SJID}} ->
try
JID = exmpp_jid:string_to_jid(SJID),
JID = exmpp_jid:list_to_jid(SJID),
user_roster_subscribe_jid(User, Server, JID),
ok
catch
@ -911,7 +911,7 @@ user_roster_item_parse_query(User, Server, Items, Query) ->
{value, _} ->
UJID = exmpp_jid:make_bare_jid(User, Server),
Attrs1 = exmpp_xml:set_attribute_in_list([],
'jid', exmpp_jid:jid_to_string(JID)),
'jid', exmpp_jid:jid_to_list(JID)),
Attrs2 = exmpp_xml:set_attribute_in_list(Attrs1,
'subscription', "remove"),
Item = #xmlel{ns = ?NS_ROSTER, name = 'item',
@ -933,7 +933,7 @@ user_roster_item_parse_query(User, Server, Items, Query) ->
nothing.
us_to_list({User, Server}) ->
exmpp_jid:bare_jid_to_string(User, Server).
exmpp_jid:bare_jid_to_list(User, Server).
webadmin_user(Acc, _User, _Server, Lang) ->
Acc ++ [?XE("h3", [?ACT("roster/", "Roster")])].

View File

@ -303,7 +303,7 @@ set_vcard(User, LServer, VCARD) ->
#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs =
[#xmlattr{name = 'type', value = "form"}], children =
[#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Search users in ") ++ exmpp_jid:jid_to_string(JID))}]},
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Search users in ") ++ exmpp_jid:jid_to_list(JID))}]},
#xmlel{ns = ?NS_SEARCH, name = 'instructions', children =
[#xmlcdata{cdata = list_to_binary(translate:translate(Lang,
"Fill in the form to search "
@ -459,7 +459,7 @@ search_result(Lang, JID, ServerHost, Data) ->
[#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children =
[#xmlcdata{cdata = list_to_binary(
translate:translate(Lang, "Search Results for ") ++
exmpp_jid:jid_to_string(JID))}]},
exmpp_jid:jid_to_list(JID))}]},
#xmlel{ns = ?NS_DATA_FORMS, name = 'reported', children =
[?TLFIELD("text-single", "Jabber ID", "jid"),
?TLFIELD("text-single", "Full Name", "fn"),