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

Update to use the new exmpp_xml:get_attribute/{3,4} API.

SVN Revision: 1514
This commit is contained in:
Jean-Sébastien Pédron 2008-08-06 13:46:23 +00:00
parent d9a493561b
commit cb20c9b0d7
6 changed files with 25 additions and 21 deletions

View File

@ -4,6 +4,10 @@
src/mod_last.erl, src/mod_configure2.erl, src/mod_last_odbc.erl, src/mod_last.erl, src/mod_configure2.erl, src/mod_last_odbc.erl,
src/gen_iq_handler.erl: Convert to exmpp. src/gen_iq_handler.erl: Convert to exmpp.
* src/adhoc.erl, src/mod_configure.erl, src/mod_roster.erl,
src/mod_disco.erl, src/mod_caps.erl: Update to use the new
exmpp_xml:get_attribute/{3,4} API.
2008-07-25 Jean-Sébastien Pédron <js.pedron@meetic-corp.com> 2008-07-25 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/adhoc.erl, src/mod_configure.erl, src/mod_announce.erl, * src/adhoc.erl, src/mod_configure.erl, src/mod_announce.erl,

View File

@ -45,9 +45,9 @@ parse_request(IQ) ->
{set, ?NS_ADHOC} -> {set, ?NS_ADHOC} ->
?DEBUG("entering parse_request...", []), ?DEBUG("entering parse_request...", []),
Lang = exmpp_stanza:get_lang(IQ), Lang = exmpp_stanza:get_lang(IQ),
Node = exmpp_xml:get_attribute(SubEl, 'node'), Node = exmpp_xml:get_attribute(SubEl, 'node', ""),
SessionID = exmpp_xml:get_attribute(SubEl, 'sessionid'), SessionID = exmpp_xml:get_attribute(SubEl, 'sessionid', ""),
Action = exmpp_xml:get_attribute(SubEl, 'action'), Action = exmpp_xml:get_attribute(SubEl, 'action', ""),
XData = find_xdata_el(SubEl), XData = find_xdata_el(SubEl),
AllEls = SubEl#xmlel.ns, AllEls = SubEl#xmlel.ns,
if XData -> if XData ->

View File

@ -69,9 +69,9 @@
read_caps(Els) -> read_caps(Els) ->
read_caps(Els, nothing). read_caps(Els, nothing).
read_caps([#xmlel{ns = ?NS_CAPS, name = 'c'} = El | Tail], _Result) -> read_caps([#xmlel{ns = ?NS_CAPS, name = 'c'} = El | Tail], _Result) ->
Node = exmpp_xml:get_attribute(El, 'node'), Node = exmpp_xml:get_attribute(El, 'node', ""),
Version = exmpp_xml:get_attribute(El, 'ver'), Version = exmpp_xml:get_attribute(El, 'ver', ""),
Exts = string:tokens(exmpp_xml:get_attribute(El, 'ext'), " "), Exts = string:tokens(exmpp_xml:get_attribute(El, 'ext', ""), " "),
read_caps(Tail, #caps{node = Node, version = Version, exts = Exts}); read_caps(Tail, #caps{node = Node, version = Version, exts = Exts});
read_caps([#xmlel{ns = ?NS_MUC_USER, name = 'x'} | _Tail], _Result) -> read_caps([#xmlel{ns = ?NS_MUC_USER, name = 'x'} | _Tail], _Result) ->
nothing; nothing;
@ -226,7 +226,7 @@ handle_cast({disco_response, From, _To, IQ},
{ok, {Node, SubNode}} -> {ok, {Node, SubNode}} ->
Features = Features =
lists:flatmap(fun(#xmlel{name = 'feature'} = F) -> lists:flatmap(fun(#xmlel{name = 'feature'} = F) ->
[exmpp_xml:get_attribute(F, 'var')]; [exmpp_xml:get_attribute(F, 'var', "")];
(_) -> (_) ->
[] []
end, Els), end, Els),

View File

@ -315,7 +315,7 @@ adhoc_local_items(Acc, From, #jid{ldomain = LServer, domain = Server} = To,
Nodes = recursively_get_local_items(LServer, "", Server, Lang), Nodes = recursively_get_local_items(LServer, "", Server, Lang),
Nodes1 = lists:filter( Nodes1 = lists:filter(
fun(N) -> fun(N) ->
Nd = exmpp_xml:get_attribute(N, 'node'), Nd = exmpp_xml:get_attribute(N, 'node', ""),
F = get_local_features([], From, To, Nd, Lang), F = get_local_features([], From, To, Nd, Lang),
case F of case F of
{result, [?NS_ADHOC_s]} -> {result, [?NS_ADHOC_s]} ->
@ -346,8 +346,8 @@ recursively_get_local_items(LServer, Node, Server, Lang) ->
Nodes = lists:flatten( Nodes = lists:flatten(
lists:map( lists:map(
fun(N) -> fun(N) ->
S = exmpp_xml:get_attribute(N, 'jid'), S = exmpp_xml:get_attribute(N, 'jid', ""),
Nd = exmpp_xml:get_attribute(N, 'node'), Nd = exmpp_xml:get_attribute(N, 'node', ""),
if (S /= Server) or (Nd == "") -> if (S /= Server) or (Nd == "") ->
[]; [];
true -> true ->

View File

@ -132,7 +132,7 @@ process_local_iq_items(From, To, IQ) ->
exmpp_iq:error(IQ, 'not-allowed'); exmpp_iq:error(IQ, 'not-allowed');
get -> get ->
SubEl = exmpp_iq:get_request(IQ), SubEl = exmpp_iq:get_request(IQ),
Node = exmpp_xml:get_attribute(SubEl, 'node'), Node = exmpp_xml:get_attribute(SubEl, 'node', ""),
Host = To#jid.ldomain, Host = To#jid.ldomain,
Lang = exmpp_stanza:get_lang(IQ), Lang = exmpp_stanza:get_lang(IQ),
@ -166,7 +166,7 @@ process_local_iq_info(From, To, IQ) ->
get -> get ->
Host = To#jid.ldomain, Host = To#jid.ldomain,
SubEl = exmpp_iq:get_request(IQ), SubEl = exmpp_iq:get_request(IQ),
Node = exmpp_xml:get_attribute(SubEl, 'node'), Node = exmpp_xml:get_attribute(SubEl, 'node', ""),
Lang = exmpp_stanza:get_lang(IQ), Lang = exmpp_stanza:get_lang(IQ),
% XXX OLD FORMAT: From, To. % XXX OLD FORMAT: From, To.
FromOld = jlib:to_old_jid(From), FromOld = jlib:to_old_jid(From),
@ -290,7 +290,7 @@ process_sm_iq_items(From, To, IQ) ->
#jid{lnode = LTo, ldomain = ToServer} = To, #jid{lnode = LTo, ldomain = ToServer} = To,
#jid{lnode = LFrom, ldomain = LServer} = From, #jid{lnode = LFrom, ldomain = LServer} = From,
Self = (LTo == LFrom) andalso (ToServer == LServer), Self = (LTo == LFrom) andalso (ToServer == LServer),
Node = exmpp_xml:get_attribute(SubEl, 'node'), Node = exmpp_xml:get_attribute(SubEl, 'node', ""),
if if
Self, Node /= [] -> Self, Node /= [] ->
%% Here, we treat disco publish attempts to your own JID. %% Here, we treat disco publish attempts to your own JID.
@ -307,7 +307,7 @@ process_sm_iq_items(From, To, IQ) ->
end; end;
get -> get ->
Host = To#jid.ldomain, Host = To#jid.ldomain,
Node = exmpp_xml:get_attribute(SubEl, 'node'), Node = exmpp_xml:get_attribute(SubEl, 'node', ""),
Lang = exmpp_stanza:get_lang(IQ), Lang = exmpp_stanza:get_lang(IQ),
% XXX OLD FORMAT: From, To. % XXX OLD FORMAT: From, To.
FromOld = jlib:to_old_jid(From), FromOld = jlib:to_old_jid(From),
@ -366,7 +366,7 @@ process_sm_iq_info(From, To, IQ) ->
get -> get ->
Host = To#jid.ldomain, Host = To#jid.ldomain,
SubEl = exmpp_iq:get_request(IQ), SubEl = exmpp_iq:get_request(IQ),
Node = exmpp_xml:get_attribute(SubEl, 'node'), Node = exmpp_xml:get_attribute(SubEl, 'node', ""),
Lang = exmpp_stanza:get_lang(IQ), Lang = exmpp_stanza:get_lang(IQ),
% XXX OLD FORMAT: From, To. % XXX OLD FORMAT: From, To.
FromOld = jlib:to_old_jid(From), FromOld = jlib:to_old_jid(From),
@ -441,10 +441,10 @@ process_disco_publish(User, Node, Items) ->
F = fun() -> F = fun() ->
lists:foreach( lists:foreach(
fun(#xmlel{} = Item) -> fun(#xmlel{} = Item) ->
Action = exmpp_xml:get_attribute(Item, 'action'), Action = exmpp_xml:get_attribute(Item, 'action', ""),
Jid = exmpp_xml:get_attribute(Item, 'jid'), Jid = exmpp_xml:get_attribute(Item, 'jid', ""),
PNode = exmpp_xml:get_attribute(Item, 'node'), PNode = exmpp_xml:get_attribute(Item, 'node', ""),
Name = exmpp_xml:get_attribute(Item, 'name'), Name = exmpp_xml:get_attribute(Item, 'name', ""),
?INFO_MSG("Disco publish: ~p ~p ~p ~p ~p ~p~n", ?INFO_MSG("Disco publish: ~p ~p ~p ~p ~p ~p~n",
[User, Action, Node, Jid, PNode, Name]), [User, Action, Node, Jid, PNode, Name]),

View File

@ -194,7 +194,7 @@ process_iq_set(From, To, IQ) ->
process_item_set(From, To, #xmlel{} = Item) -> process_item_set(From, To, #xmlel{} = Item) ->
try try
JID1 = exmpp_jid:string_to_jid(exmpp_xml:get_attribute(Item, 'jid')), JID1 = exmpp_jid:string_to_jid(exmpp_xml:get_attribute(Item, 'jid', "")),
% XXX OLD FORMAT: old JID (with empty strings). % XXX OLD FORMAT: old JID (with empty strings).
#jid{node = User, lnode = LUser, ldomain = LServer} = #jid{node = User, lnode = LUser, ldomain = LServer} =
jlib:to_old_jid(From), jlib:to_old_jid(From),
@ -587,7 +587,7 @@ set_items(User, Server, SubEl) ->
process_item_set_t(LUser, LServer, #xmlel{} = El) -> process_item_set_t(LUser, LServer, #xmlel{} = El) ->
try try
JID1 = exmpp_jid:string_to_jid(exmpp_xml:get_attribute(El, 'jid')), JID1 = exmpp_jid:string_to_jid(exmpp_xml:get_attribute(El, 'jid', "")),
JID = {JID1#jid.node, JID1#jid.domain, JID1#jid.resource}, JID = {JID1#jid.node, JID1#jid.domain, JID1#jid.resource},
LJID = {JID1#jid.lnode, JID1#jid.ldomain, JID1#jid.lresource}, LJID = {JID1#jid.lnode, JID1#jid.ldomain, JID1#jid.lresource},
Item = #roster{usj = {LUser, LServer, LJID}, Item = #roster{usj = {LUser, LServer, LJID},