mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
o Add function to convert to and from old ejabberd #jid record.
o Move function short_jid/1 from ejabberd_c2s. SVN Revision: 1390
This commit is contained in:
parent
264e72830b
commit
290040ad9d
@ -9,6 +9,9 @@
|
||||
|
||||
* src/ejabberd_s2s.erl: Convert to exmpp.
|
||||
|
||||
* src/jlib.erl: Add function to convert to and from old ejabberd #jid
|
||||
record. Move function short_jid/1 from ejabberd_c2s.
|
||||
|
||||
2008-06-27 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
|
||||
|
||||
* src/ejabberd_c2s.erl, src/ejabberd_s2s_out.erl,
|
||||
|
53
src/jlib.erl
53
src/jlib.erl
@ -60,7 +60,10 @@
|
||||
datetime_string_to_timestamp/1,
|
||||
decode_base64/1,
|
||||
encode_base64/1,
|
||||
ip_to_list/1]).
|
||||
ip_to_list/1,
|
||||
from_old_jid/1,
|
||||
to_old_jid/1,
|
||||
short_jid/1]).
|
||||
|
||||
-include("jlib.hrl").
|
||||
|
||||
@ -683,3 +686,51 @@ ip_to_list({IP, _Port}) ->
|
||||
ip_to_list(IP);
|
||||
ip_to_list({A,B,C,D}) ->
|
||||
lists:flatten(io_lib:format("~w.~w.~w.~w",[A,B,C,D])).
|
||||
|
||||
% --------------------------------------------------------------------
|
||||
% Compat layer.
|
||||
% --------------------------------------------------------------------
|
||||
|
||||
%% @spec (JID) -> New_JID
|
||||
%% JID = jid()
|
||||
%% New_JID = jid()
|
||||
%% @doc Convert a JID from its ejabberd form to its exmpp form.
|
||||
%%
|
||||
%% Empty fields are set to `undefined', not the empty string.
|
||||
|
||||
from_old_jid(#jid{user = Node, resource = Resource,
|
||||
luser = LNode, lresource = LResource} = JID) ->
|
||||
{Node1, LNode1} = case Node of
|
||||
"" -> {undefined, undefined};
|
||||
_ -> {Node, LNode}
|
||||
end,
|
||||
{Resource1, LResource1} = case Resource of
|
||||
"" -> {undefined, undefined};
|
||||
_ -> {Resource, LResource}
|
||||
end,
|
||||
JID#jid{user = Node1, resource = Resource1,
|
||||
luser = LNode1, lresource = LResource1}.
|
||||
|
||||
%% @spec (JID) -> New_JID
|
||||
%% JID = jid()
|
||||
%% New_JID = jid()
|
||||
%% @doc Convert a JID from its exmpp form to its ejabberd form.
|
||||
%%
|
||||
%% Empty fields are set to the empty string, not `undefined'.
|
||||
|
||||
to_old_jid(#jid{user = Node, resource = Resource,
|
||||
luser = LNode, lresource = LResource} = JID) ->
|
||||
{Node1, LNode1} = case Node of
|
||||
undefined -> {"", ""};
|
||||
_ -> {Node, LNode}
|
||||
end,
|
||||
{Resource1, LResource1} = case Resource of
|
||||
undefined -> {"", ""};
|
||||
_ -> {Resource, LResource}
|
||||
end,
|
||||
JID#jid{user = Node1, resource = Resource1,
|
||||
luser = LNode1, lresource = LResource1}.
|
||||
|
||||
short_jid(JID0) ->
|
||||
JID = to_old_jid(JID0),
|
||||
{JID#jid.luser, JID#jid.lserver, JID#jid.lresource}.
|
||||
|
Loading…
Reference in New Issue
Block a user