diff --git a/ChangeLog b/ChangeLog index 0ef9fe049..792cc377f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 * src/adhoc.erl, src/mod_configure.erl, src/mod_announce.erl, diff --git a/src/adhoc.erl b/src/adhoc.erl index a35dc763f..b338df068 100644 --- a/src/adhoc.erl +++ b/src/adhoc.erl @@ -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 -> diff --git a/src/mod_caps.erl b/src/mod_caps.erl index 9b3bef70b..3cb1b8530 100644 --- a/src/mod_caps.erl +++ b/src/mod_caps.erl @@ -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), diff --git a/src/mod_configure.erl b/src/mod_configure.erl index c8925277e..f62d1926a 100644 --- a/src/mod_configure.erl +++ b/src/mod_configure.erl @@ -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 -> diff --git a/src/mod_disco.erl b/src/mod_disco.erl index 9700a6546..a2e9e4feb 100644 --- a/src/mod_disco.erl +++ b/src/mod_disco.erl @@ -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]), diff --git a/src/mod_roster.erl b/src/mod_roster.erl index 4e7e5ecab..9d7211cc9 100644 --- a/src/mod_roster.erl +++ b/src/mod_roster.erl @@ -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},