25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +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/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>
* src/adhoc.erl, src/mod_configure.erl, src/mod_announce.erl,

View File

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

View File

@ -69,9 +69,9 @@
read_caps(Els) ->
read_caps(Els, nothing).
read_caps([#xmlel{ns = ?NS_CAPS, name = 'c'} = El | Tail], _Result) ->
Node = exmpp_xml:get_attribute(El, 'node'),
Version = exmpp_xml:get_attribute(El, 'ver'),
Exts = string:tokens(exmpp_xml:get_attribute(El, 'ext'), " "),
Node = exmpp_xml:get_attribute(El, 'node', ""),
Version = exmpp_xml:get_attribute(El, 'ver', ""),
Exts = string:tokens(exmpp_xml:get_attribute(El, 'ext', ""), " "),
read_caps(Tail, #caps{node = Node, version = Version, exts = Exts});
read_caps([#xmlel{ns = ?NS_MUC_USER, name = 'x'} | _Tail], _Result) ->
nothing;
@ -226,7 +226,7 @@ handle_cast({disco_response, From, _To, IQ},
{ok, {Node, SubNode}} ->
Features =
lists:flatmap(fun(#xmlel{name = 'feature'} = F) ->
[exmpp_xml:get_attribute(F, 'var')];
[exmpp_xml:get_attribute(F, 'var', "")];
(_) ->
[]
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),
Nodes1 = lists:filter(
fun(N) ->
Nd = exmpp_xml:get_attribute(N, 'node'),
Nd = exmpp_xml:get_attribute(N, 'node', ""),
F = get_local_features([], From, To, Nd, Lang),
case F of
{result, [?NS_ADHOC_s]} ->
@ -346,8 +346,8 @@ recursively_get_local_items(LServer, Node, Server, Lang) ->
Nodes = lists:flatten(
lists:map(
fun(N) ->
S = exmpp_xml:get_attribute(N, 'jid'),
Nd = exmpp_xml:get_attribute(N, 'node'),
S = exmpp_xml:get_attribute(N, 'jid', ""),
Nd = exmpp_xml:get_attribute(N, 'node', ""),
if (S /= Server) or (Nd == "") ->
[];
true ->

View File

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