From ef572c815f50f9112aca11c9f2b4af918443ab66 Mon Sep 17 00:00:00 2001 From: Pablo Polvorin Date: Mon, 29 Nov 2010 16:44:31 -0300 Subject: [PATCH] Port to latest exmpp changes (attribute names as binary()). All atributes are now binary() instead of atoms. --- src/adhoc.erl | 16 +- src/ejabberd_c2s.erl | 24 +- src/ejabberd_captcha.erl | 68 ++--- src/ejabberd_piefxis.erl | 12 +- src/ejabberd_receiver.erl | 1 - src/ejabberd_router.erl | 4 +- src/ejabberd_sm.erl | 2 +- src/jd2ejd.erl | 4 +- src/jlib.erl | 12 +- src/mod_adhoc.erl | 36 +-- src/mod_announce.erl | 40 +-- src/mod_caps.erl | 36 +-- src/mod_configure.erl | 264 +++++++++--------- src/mod_configure2.erl | 10 +- src/mod_disco.erl | 38 +-- src/mod_last.erl | 6 +- src/mod_last_odbc.erl | 4 +- src/mod_muc/mod_muc.erl | 32 +-- src/mod_muc/mod_muc_room.erl | 180 ++++++------- src/mod_multicast.erl | 47 ++-- src/mod_offline.erl | 18 +- src/mod_offline_odbc.erl | 16 +- src/mod_privacy.erl | 34 +-- src/mod_privacy_odbc.erl | 32 +-- src/mod_private_odbc.erl | 2 +- src/mod_proxy65/mod_proxy65_service.erl | 14 +- src/mod_pubsub/mod_pubsub.erl | 278 +++++++++---------- src/mod_pubsub/mod_pubsub_odbc.erl | 280 ++++++++++---------- src/mod_pubsub/pubsub_odbc.patch | 32 +-- src/mod_pubsub/pubsub_subscription.erl | 8 +- src/mod_pubsub/pubsub_subscription_odbc.erl | 6 +- src/mod_register.erl | 12 +- src/mod_roster.erl | 64 ++--- src/mod_roster_odbc.erl | 62 ++--- src/mod_shared_roster.erl | 14 +- src/mod_stats.erl | 16 +- src/mod_vcard.erl | 28 +- src/mod_vcard_ldap.erl | 22 +- src/mod_vcard_odbc.erl | 24 +- src/mod_vcard_xupdate.erl | 2 +- src/web/ejabberd_http_bind.erl | 74 +++--- src/web/ejabberd_http_poll.erl | 4 +- src/web/ejabberd_web.erl | 16 +- src/web/ejabberd_web_admin.erl | 170 ++++++------ src/web/mod_http_bind.erl | 4 +- src/web/mod_register_web.erl | 14 +- 46 files changed, 1041 insertions(+), 1041 deletions(-) diff --git a/src/adhoc.erl b/src/adhoc.erl index e84c29efa..6bd825f12 100644 --- a/src/adhoc.erl +++ b/src/adhoc.erl @@ -43,9 +43,9 @@ parse_request(#iq{type = Type, ns = NS, payload = SubEl, lang = Lang}) -> case {Type, NS} of {set, ?NS_ADHOC} -> ?DEBUG("entering parse_request...", []), - Node = exmpp_xml:get_attribute_as_list(SubEl, 'node', ""), - SessionID = exmpp_xml:get_attribute_as_list(SubEl, 'sessionid', ""), - Action = exmpp_xml:get_attribute_as_list(SubEl, 'action', ""), + Node = exmpp_xml:get_attribute_as_list(SubEl, <<"node">>, ""), + SessionID = exmpp_xml:get_attribute_as_list(SubEl, <<"sessionid">>, ""), + Action = exmpp_xml:get_attribute_as_list(SubEl, <<"action">>, ""), XData = find_xdata_el(SubEl), AllEls = exmpp_xml:get_child_elements(SubEl), Others = case XData of @@ -114,7 +114,7 @@ produce_response(#adhoc_response{lang = _Lang, "" -> ActionsElAttrs = []; _ -> - ActionsElAttrs = [?XMLATTR('execute', DefaultAction)] + ActionsElAttrs = [?XMLATTR(<<"execute">>, DefaultAction)] end, ActionsEls = [#xmlel{ns = ?NS_ADHOC, name = 'actions', attrs = ActionsElAttrs, children = @@ -122,11 +122,11 @@ produce_response(#adhoc_response{lang = _Lang, end, NotesEls = lists:map(fun({Type, Text}) -> #xmlel{ns = ?NS_ADHOC, name = 'note', attrs = - [?XMLATTR('type', Type)], + [?XMLATTR(<<"type">>, Type)], children = [#xmlcdata{cdata = list_to_binary(Text)}]} end, Notes), #xmlel{ns = ?NS_ADHOC, name = 'command', attrs = - [?XMLATTR('sessionid', SessionID), - ?XMLATTR('node', Node), - ?XMLATTR('status', Status)], children = + [?XMLATTR(<<"sessionid">>, SessionID), + ?XMLATTR(<<"node">>, Node), + ?XMLATTR(<<"status">>, Status)], children = ActionsEls ++ NotesEls ++ Elements}. diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index 8af5f47a7..5067c8585 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -1256,17 +1256,17 @@ handle_info({route, From, To, Packet}, StateName, StateData) -> ?DEBUG("broadcast~n~p~n", [Packet#xmlel.children]), case Packet#xmlel.ns of roster_item -> - IJID = exmpp_jid:make(exmpp_xml:get_attribute(Packet, u, <<"">>), - exmpp_xml:get_attribute(Packet, s, <<"">>), - exmpp_xml:get_attribute(Packet, r, <<"">>)), - ISubscription = exmpp_xml:get_attribute(Packet, subs, <<"none">>), + IJID = exmpp_jid:make(exmpp_xml:get_attribute(Packet, <<"u">>, <<"">>), + exmpp_xml:get_attribute(Packet, <<"s">>, <<"">>), + exmpp_xml:get_attribute(Packet, <<"r">>, <<"">>)), + ISubscription = exmpp_xml:get_attribute(Packet, <<"subs">>, <<"none">>), {false, Attrs, roster_change(IJID, ISubscription, StateData)}; exit -> - Reason = exmpp_xml:get_attribute_as_list(Packet, reason, "Unknown reason"), + Reason = exmpp_xml:get_attribute_as_list(Packet, <<"reason">>, "Unknown reason"), {exit, Attrs, Reason}; privacy_list -> - PrivListName = exmpp_xml:get_attribute_as_list(Packet, list_name, "Unknown list name"), + PrivListName = exmpp_xml:get_attribute_as_list(Packet, <<"list_name">>, "Unknown list name"), CDataString = exmpp_xml:get_cdata_as_list(Packet), {ok, A2, _} = erl_scan:string(CDataString), {_, W} = erl_parse:parse_exprs(A2), @@ -1516,22 +1516,22 @@ send_header(StateData, Server, Version, Lang) VersionAttr = case Version of "" -> []; - _ -> [{"version", Version}] + _ -> [?XMLATTR(<<"version">>, Version)] end, LangAttr = case Lang of "" -> []; - _ -> [{"xml:lang", Lang}] + _ -> [?XMLATTR(<<"xml:lang">>, Lang)] end, Header = {xmlstreamstart, "stream:stream", VersionAttr ++ LangAttr ++ - [{"xmlns", "jabber:client"}, - {"xmlns:stream", "http://etherx.jabber.org/streams"}, - {"id", StateData#state.streamid}, - {"from", Server}]}, + [?XMLATTR(<<"xmlns">>, "jabber:client"), + ?XMLATTR(<<"xmlns:stream">>, "http://etherx.jabber.org/streams"), + ?XMLATTR(<<"id">>, StateData#state.streamid), + ?XMLATTR(<<"from">>, Server)]}, (StateData#state.sockmod):send_xml( StateData#state.socket, Header); send_header(StateData, Server, Version, Lang) -> diff --git a/src/ejabberd_captcha.erl b/src/ejabberd_captcha.erl index 906d3968c..688996adf 100644 --- a/src/ejabberd_captcha.erl +++ b/src/ejabberd_captcha.erl @@ -64,10 +64,10 @@ -define(VFIELD(Type, Var, Value), #xmlel{name = 'field', attrs = [ - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, value = Type }, - #xmlattr{name = 'var', + #xmlattr{name = <<"var">>, value = Var } ], @@ -111,13 +111,13 @@ create_captcha(SID, From, To, Lang, Args) name = 'data', ns = ?NS_BOB, attrs = [ - #xmlattr{name = 'cid', + #xmlattr{name = <<"cid">>, value = CID }, - #xmlattr{name = 'max-age', + #xmlattr{name = <<"max-age">>, value = <<"0">> }, - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, value = Type } ], @@ -142,7 +142,7 @@ create_captcha(SID, From, To, Lang, Args) #xmlel{name = 'x', ns = ?NS_DATA_FORMS_s, attrs = [ - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, value = <<"form">> } ], @@ -153,10 +153,10 @@ create_captcha(SID, From, To, Lang, Args) ?VFIELD(<<"hidden">>, <<"sid">>, #xmlcdata{cdata = SID}), #xmlel{name = 'field', attrs = [ - #xmlattr{name = 'var', + #xmlattr{name = <<"var">>, value = <<"ocr">> }, - #xmlattr{name = 'label', + #xmlattr{name = <<"label">>, value = ?CAPTCHA_TEXT(Lang) } ], @@ -167,7 +167,7 @@ create_captcha(SID, From, To, Lang, Args) children = [ #xmlel{name = 'uri', attrs = [ - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, value = Type } ], @@ -229,13 +229,13 @@ create_captcha_x(SID, To, Lang, HeadEls, TailEls) -> name = 'data', ns = ?NS_BOB, attrs = [ - #xmlattr{name = 'cid', + #xmlattr{name = <<"cid">>, value = CID }, - #xmlattr{name = 'max-age', + #xmlattr{name = <<"max-age">>, value = <<"0">> }, - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, value = Type } ], @@ -249,25 +249,25 @@ create_captcha_x(SID, To, Lang, HeadEls, TailEls) -> #xmlel{name = 'x', ns = ?NS_DATA_FORMS_s, attrs = [ - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, value = <<"form">> } ], children = [ ?VFIELD(<<"hidden">>, <<"FORM_TYPE">>, #xmlcdata{cdata = ?NS_CAPTCHA_b}) | HeadEls] ++ [ #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"fixed">>), ?XMLATTR('label', HelpTxt)]}, + [?XMLATTR(<<"type">>, <<"fixed">>), ?XMLATTR(<<"label">>, HelpTxt)]}, ?VFIELD(<<"hidden">>, <<"captchahidden">>, #xmlcdata{cdata = <<"workaround-for-psi">>}), #xmlel{name = 'field', attrs = [ - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, value = <<"text-single">> }, - #xmlattr{name = 'label', + #xmlattr{name = <<"label">>, value = list_to_binary(translate:translate(Lang, "CAPTCHA web page")) }, - #xmlattr{name = 'var', + #xmlattr{name = <<"var">>, value = <<"url">> } ], @@ -281,10 +281,10 @@ create_captcha_x(SID, To, Lang, HeadEls, TailEls) -> ?VFIELD(<<"hidden">>, <<"sid">>, #xmlcdata{cdata = SID}), #xmlel{name = 'field', attrs = [ - #xmlattr{name = 'var', + #xmlattr{name = <<"var">>, value = <<"ocr">> }, - #xmlattr{name = 'label', + #xmlattr{name = <<"label">>, value = ?CAPTCHA_TEXT(Lang) } ], @@ -295,7 +295,7 @@ create_captcha_x(SID, To, Lang, HeadEls, TailEls) -> children = [ #xmlel{name = 'uri', attrs = [ - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, value = Type } ], @@ -329,7 +329,7 @@ build_captcha_html(Id, Lang) -> ImgEl = #xmlel{name = 'img', attrs = [ - #xmlattr{name = 'src', + #xmlattr{name = <<"src">>, value = list_to_binary(get_url(Id ++ "/image")) } ] @@ -342,13 +342,13 @@ build_captcha_html(Id, Lang) -> IdEl = #xmlel{name = 'input', attrs = [ - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, value = <<"hidden">> }, - #xmlattr{name = 'name', + #xmlattr{name = <<"name">>, value = <<"id">> }, - #xmlattr{name = 'value', + #xmlattr{name = <<"value">>, value = list_to_binary(Id) } ] @@ -359,13 +359,13 @@ build_captcha_html(Id, Lang) -> KeyEl = #xmlel{name = 'input', attrs = [ - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, value = <<"text">> }, - #xmlattr{name = 'name', + #xmlattr{name = <<"name">>, value = <<"key">> }, - #xmlattr{name = 'size', + #xmlattr{name = <<"size">>, value = <<"10">> } ] @@ -387,13 +387,13 @@ build_captcha_html(Id, Lang) -> FormEl = #xmlel{name = 'form', attrs = [ - #xmlattr{name = 'action', + #xmlattr{name = <<"action">>, value = list_to_binary(get_url(Id)) }, - #xmlattr{name = 'name', + #xmlattr{name = <<"name">>, value = <<"captcha">> }, - #xmlattr{name = 'method', + #xmlattr{name = <<"method">>, value = <<"POST">> } ], @@ -410,13 +410,13 @@ build_captcha_html(Id, Lang) -> }, #xmlel{name = 'input', attrs = [ - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, value = <<"submit">> }, - #xmlattr{name = 'name', + #xmlattr{name = <<"name">>, value = <<"enter">> }, - #xmlattr{name = 'value', + #xmlattr{name = <<"value">>, value = <<"OK">> } ] @@ -481,7 +481,7 @@ process(_Handlers, #request{method='GET', lang=Lang, path=[_, Id]}) -> %[FormEl]}, #xmlel{name = 'div', attrs = [ - #xmlattr{name = 'align', + #xmlattr{name = <<"align">>, value = <<"center">> } ], diff --git a/src/ejabberd_piefxis.erl b/src/ejabberd_piefxis.erl index 82cda1e2b..ecfadb14f 100644 --- a/src/ejabberd_piefxis.erl +++ b/src/ejabberd_piefxis.erl @@ -123,13 +123,13 @@ process_element(El=#xmlel{name=user, ns=_XMLNS}, State; process_element(H=#xmlel{name=host},State) -> - State#parsing_state{host=exmpp_xml:get_attribute(H,"jid",none)}; + State#parsing_state{host=exmpp_xml:get_attribute(H,<<"jid">>,none)}; process_element(#xmlel{name='server-data'},State) -> State; process_element(El=#xmlel{name=include, ns=?NS_XINCLUDE}, State=#parsing_state{dir=Dir}) -> - case exmpp_xml:get_attribute(El, href, none) of + case exmpp_xml:get_attribute(El, <<"href">>, none) of none -> ok; HrefB -> @@ -158,8 +158,8 @@ process_element(El,State) -> %%%% Add user add_user(El, Domain) -> - User = exmpp_xml:get_attribute(El,name,none), - Password = exmpp_xml:get_attribute(El,password,none), + User = exmpp_xml:get_attribute(El,<<"name">>,none), + Password = exmpp_xml:get_attribute(El,<<"password">>,none), add_user(El, Domain, User, Password). %% @spec (El::xmlel(), Domain::string(), User::string(), Password::string()) @@ -301,7 +301,7 @@ populate_user(User,Domain,El=#xmlel{name='offline-messages'}) -> fun (_Element, {xmlcdata, _}) -> ok; (_Element, Child) -> - From = exmpp_xml:get_attribute(Child,from,none), + From = exmpp_xml:get_attribute(Child,<<"from">>,none), FullFrom = exmpp_jid:parse(From), FullUser = exmpp_jid:make(User, Domain), _R = M:store_packet(FullFrom, FullUser, Child) @@ -558,7 +558,7 @@ mnesia_pop_offline_messages(Ls, User, Server) -> fun(R) -> [Packet] = exmpp_xml:parse_document(R#offline_msg.packet, [names_as_atom]), FromString = exmpp_jid:prep_to_list(R#offline_msg.from), - Packet2 = exmpp_xml:set_attribute(Packet, "from", FromString), + Packet2 = exmpp_xml:set_attribute(Packet, <<"from">>, FromString), Packet3 = Packet2#xmlel{ns = ?NS_JABBER_CLIENT}, exmpp_xml:append_children( Packet3, diff --git a/src/ejabberd_receiver.erl b/src/ejabberd_receiver.erl index 76a24c542..ca1584d97 100644 --- a/src/ejabberd_receiver.erl +++ b/src/ejabberd_receiver.erl @@ -443,7 +443,6 @@ new_xmlstream(C2SPid, MaxStanzaSize) -> Parser = exmpp_xml:start_parser([{names_as_atom, true}, {check_nss, xmpp}, {check_elems, xmpp}, - {check_attrs, xmpp}, {max_size, MaxStanzaSize} ]), exmpp_xmlstream:start({gen_fsm, C2SPid}, Parser, diff --git a/src/ejabberd_router.erl b/src/ejabberd_router.erl index f9bc0ab76..c8dbaa30d 100644 --- a/src/ejabberd_router.erl +++ b/src/ejabberd_router.erl @@ -370,9 +370,9 @@ code_change(_OldVsn, State, _Extra) -> %%% Internal functions %%-------------------------------------------------------------------- route_check_id(From, To, #xmlel{name = iq} = Packet) -> - case exmpp_xml:get_attribute_as_list(Packet, 'id', "") of + case exmpp_xml:get_attribute_as_list(Packet, <<"id">>, "") of ?ROUTE_PREFIX ++ Rest -> - Type = exmpp_xml:get_attribute_as_list(Packet, 'type', ""), + Type = exmpp_xml:get_attribute_as_list(Packet, <<"type">>, ""), if Type == "error"; Type == "result" -> case string:tokens(Rest, "-") of [_, NodeID] -> diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index 4afeb08e7..c5eb9e52d 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -155,7 +155,7 @@ disconnect_removed_user(User, Server) -> exmpp_jid:make(User, Server), #xmlel{name = 'broadcast', ns = exit, - attrs = [exmpp_xml:attribute(reason, "User removed")]}). + attrs = [?XMLATTR(<<"reason">>, <<"User removed">>)]}). get_user_resources(User, Server) when is_binary(User), is_binary(Server) -> diff --git a/src/jd2ejd.erl b/src/jd2ejd.erl index d06ff762f..1c173371f 100644 --- a/src/jd2ejd.erl +++ b/src/jd2ejd.erl @@ -127,7 +127,7 @@ xdb_data(User, Server, #xmlel{ns = NS} = El) -> catch mod_roster:set_items(UserB, ServerB, El), ok; ?NS_LAST_ACTIVITY -> - TimeStamp = exmpp_xml:get_attribute_as_list(El, 'last', ""), + TimeStamp = exmpp_xml:get_attribute_as_list(El, <<"last">>, ""), Status = exmpp_xml:get_cdata(El), catch mod_last:store_last_info( UserB, @@ -145,7 +145,7 @@ xdb_data(User, Server, #xmlel{ns = NS} = El) -> process_offline(Server, From, El), ok; XMLNS -> - case exmpp_xml:get_attribute_as_list(El, "j_private_flag", "") of + case exmpp_xml:get_attribute_as_list(El, <<"j_private_flag">>, "") of "1" -> catch mod_private:process_sm_iq( From, diff --git a/src/jlib.erl b/src/jlib.erl index 6c65663d5..76a04fe53 100644 --- a/src/jlib.erl +++ b/src/jlib.erl @@ -57,7 +57,7 @@ %% R = binary(). parse_xdata_submit(#xmlel{attrs = Attrs, children = Els}) -> - case exmpp_xml:get_attribute_from_list_as_list(Attrs, 'type', "") of + case exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"type">>, "") of "submit" -> lists:reverse(parse_xdata_fields(Els, [])); "form" -> %% This is a workaround to accept Psi's wrong forms @@ -70,7 +70,7 @@ parse_xdata_fields([], Res) -> Res; parse_xdata_fields([#xmlel{name = 'field', attrs = Attrs, children = SubEls} | Els], Res) -> - case exmpp_xml:get_attribute_from_list_as_list(Attrs, 'var', "") of + case exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"var">>, "") of "" -> parse_xdata_fields(Els, Res); Var -> @@ -140,7 +140,7 @@ rsm_encode_first(undefined, undefined, Arr) -> rsm_encode_first(First, undefined, Arr) -> [#xmlel{ns = ?NS_RSM, name = 'first', children = [#xmlcdata{cdata = list_to_binary(First)}]}|Arr]; rsm_encode_first(First, Index, Arr) -> - [#xmlel{ns = ?NS_RSM, name = 'first', attrs = [?XMLATTR('index', Index)], children = [#xmlcdata{cdata = list_to_binary(First)}]}|Arr]. + [#xmlel{ns = ?NS_RSM, name = 'first', attrs = [?XMLATTR(<<"index">>, Index)], children = [#xmlcdata{cdata = list_to_binary(First)}]}|Arr]. rsm_encode_last(undefined, Arr) -> Arr; rsm_encode_last(Last, Arr) -> @@ -182,8 +182,8 @@ timestamp_to_xml(DateTime, Timezone, FromJID, Desc) -> {T_string, Tz_string} = timestamp_to_iso(DateTime, Timezone), From = exmpp_jid:to_list(FromJID), P1 = exmpp_xml:set_attributes(#xmlel{ns = ?NS_DELAY, name = 'delay'}, - [{'from', From}, - {'stamp', T_string ++ Tz_string}]), + [{<<"from">>, From}, + {<<"stamp">>, T_string ++ Tz_string}]), exmpp_xml:set_cdata(P1, Desc). %% TODO: Remove this function once XEP-0091 is Obsolete @@ -192,7 +192,7 @@ timestamp_to_xml({{Year, Month, Day}, {Hour, Minute, Second}}) -> io_lib:format("~4..0w~2..0w~2..0wT~2..0w:~2..0w:~2..0w", [Year, Month, Day, Hour, Minute, Second])), exmpp_xml:set_attribute(#xmlel{ns = ?NS_DELAY_OLD, name = 'x'}, - 'stamp', Timestamp). + <<"stamp">>, Timestamp). now_to_utc_string({MegaSecs, Secs, MicroSecs}) -> {{Year, Month, Day}, {Hour, Minute, Second}} = diff --git a/src/mod_adhoc.erl b/src/mod_adhoc.erl index f1f04c214..4def479d4 100644 --- a/src/mod_adhoc.erl +++ b/src/mod_adhoc.erl @@ -95,9 +95,9 @@ get_local_commands(Acc, _From, To, <<>>, Lang) -> end, Nodes = [#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = - [?XMLATTR('jid', Server), - ?XMLATTR('node', ?NS_ADHOC_s), - ?XMLATTR('name', translate:translate(Lang, "Commands"))] + [?XMLATTR(<<"jid">>, Server), + ?XMLATTR(<<"node">>, ?NS_ADHOC_s), + ?XMLATTR(<<"name">>, translate:translate(Lang, "Commands"))] }], {result, Items ++ Nodes} end; @@ -126,9 +126,9 @@ get_sm_commands(Acc, _From, To, <<>>, Lang) -> end, Nodes = [#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(To)), - ?XMLATTR('node', ?NS_ADHOC_s), - ?XMLATTR('name', translate:translate(Lang, "Commands"))] + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(To)), + ?XMLATTR(<<"node">>, ?NS_ADHOC_s), + ?XMLATTR(<<"name">>, translate:translate(Lang, "Commands"))] }], {result, Items ++ Nodes} end; @@ -144,15 +144,15 @@ get_sm_commands(Acc, _From, _To, _Node, _Lang) -> %% On disco info request to the ad-hoc node, return automation/command-list. get_local_identity(Acc, _From, _To, ?NS_ADHOC_b, Lang) -> [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = - [?XMLATTR('category', <<"automation">>), - ?XMLATTR('type', <<"command-list">>), - ?XMLATTR('name', translate:translate(Lang, "Commands"))]} | Acc]; + [?XMLATTR(<<"category">>, <<"automation">>), + ?XMLATTR(<<"type">>, <<"command-list">>), + ?XMLATTR(<<"name">>, translate:translate(Lang, "Commands"))]} | Acc]; get_local_identity(Acc, _From, _To, <<"ping">>, Lang) -> [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = - [?XMLATTR('category', <<"automation">>), - ?XMLATTR('type', <<"command-node">>), - ?XMLATTR('name', translate:translate(Lang, "Ping"))]} | Acc]; + [?XMLATTR(<<"category">>, <<"automation">>), + ?XMLATTR(<<"type">>, <<"command-node">>), + ?XMLATTR(<<"name">>, translate:translate(Lang, "Ping"))]} | Acc]; get_local_identity(Acc, _From, _To, _Node, _Lang) -> Acc. @@ -162,9 +162,9 @@ get_local_identity(Acc, _From, _To, _Node, _Lang) -> %% On disco info request to the ad-hoc node, return automation/command-list. get_sm_identity(Acc, _From, _To, ?NS_ADHOC_s, Lang) -> [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = - [?XMLATTR('category', <<"automation">>), - ?XMLATTR('type', <<"command-list">>), - ?XMLATTR('name', translate:translate(Lang, "Commands"))]} | Acc]; + [?XMLATTR(<<"category">>, <<"automation">>), + ?XMLATTR(<<"type">>, <<"command-list">>), + ?XMLATTR(<<"name">>, translate:translate(Lang, "Commands"))]} | Acc]; get_sm_identity(Acc, _From, _To, _Node, _Lang) -> Acc. @@ -244,9 +244,9 @@ ping_item(Acc, _From, To, Lang) -> [] end, Nodes = [#xmlel{ns = ?NS_DISCO_INFO, name = 'item', attrs = - [?XMLATTR('jid', Server), - ?XMLATTR('node', <<"ping">>), - ?XMLATTR('name', translate:translate(Lang, "Ping"))]}], + [?XMLATTR(<<"jid">>, Server), + ?XMLATTR(<<"node">>, <<"ping">>), + ?XMLATTR(<<"name">>, translate:translate(Lang, "Ping"))]}], {result, Items ++ Nodes}. diff --git a/src/mod_announce.erl b/src/mod_announce.erl index 024717255..ea52dbbba 100644 --- a/src/mod_announce.erl +++ b/src/mod_announce.erl @@ -178,9 +178,9 @@ announce(From, To, Packet) -> %% Announcing via ad-hoc commands -define(INFO_COMMAND(Lang, Node), [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = - [?XMLATTR('category', <<"automation">>), - ?XMLATTR('type', <<"command-node">>), - ?XMLATTR('name', get_title(Lang, Node))]}]). + [?XMLATTR(<<"category">>, <<"automation">>), + ?XMLATTR(<<"type">>, <<"command-node">>), + ?XMLATTR(<<"name">>, get_title(Lang, Node))]}]). disco_identity(Acc, _From, _To, Node, Lang) -> LNode = tokenize(binary_to_list(Node)), @@ -276,9 +276,9 @@ disco_features(Acc, From, To, Node, _Lang) -> -define(NODE_TO_ITEM(Lang, Server, Node), #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = - [?XMLATTR('jid', Server), - ?XMLATTR('node', Node), - ?XMLATTR('name', get_title(Lang, Node))]}). + [?XMLATTR(<<"jid">>, Server), + ?XMLATTR(<<"node">>, Node), + ?XMLATTR(<<"name">>, get_title(Lang, Node))]}). -define(ITEMS_RESULT(Allow, Items), case Allow of @@ -487,8 +487,8 @@ announce_commands(From, To, _ -> [?VVALUE(Val)] end). -define(TVFIELD(Type, Var, Val), - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type), - ?XMLATTR('var', Var)], children = + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"var">>, Var)], children = ?VVALUEL(Val)}). -define(HFIELD(), ?TVFIELD(<<"hidden">>, <<"FORM_TYPE">>, list_to_binary(?NS_ADMIN_s))). @@ -501,28 +501,28 @@ generate_adhoc_form(Lang, Node, ServerHost) -> {[], []} end, #xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = - [?XMLATTR('type', <<"form">>)], children = + [?XMLATTR(<<"type">>, <<"form">>)], children = [?HFIELD(), #xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(get_title(Lang, Node))}]}] ++ if (LNode == ?NS_ADMINL("delete-motd")) or (LNode == ?NS_ADMINL("delete-motd-allhosts")) -> [#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"confirm">>), - ?XMLATTR('type', <<"boolean">>), - ?XMLATTR('label', translate:translate(Lang, "Really delete message of the day?"))], children = + [?XMLATTR(<<"var">>, <<"confirm">>), + ?XMLATTR(<<"type">>, <<"boolean">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, "Really delete message of the day?"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"true">>}]}]}]; true -> [#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"subject">>), - ?XMLATTR('type', <<"text-single">>), - ?XMLATTR('label', translate:translate(Lang, "Subject"))], children = + [?XMLATTR(<<"var">>, <<"subject">>), + ?XMLATTR(<<"type">>, <<"text-single">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, "Subject"))], children = ?VVALUEL(list_to_binary(OldSubject))}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"body">>), - ?XMLATTR('type', <<"text-multi">>), - ?XMLATTR('label', translate:translate(Lang, "Message body"))], children = + [?XMLATTR(<<"var">>, <<"body">>), + ?XMLATTR(<<"type">>, <<"text-multi">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, "Message body"))], children = ?VVALUEL(list_to_binary(OldBody))}] end}. @@ -568,7 +568,7 @@ handle_adhoc_form(From, To, node = Node, sessionid = SessionID, status = completed}, - Packet = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', attrs = [?XMLATTR('type', <<"normal">>)], children = + Packet = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', attrs = [?XMLATTR(<<"type">>, <<"normal">>)], children = if Subject /= [] -> [#xmlel{ns = ?NS_JABBER_CLIENT, name = 'subject', children = [#xmlcdata{cdata = list_to_binary(Subject)}]}]; @@ -870,7 +870,7 @@ send_announcement_to_all(Host, SubjectS, BodyS) -> true -> [] end, - Packet = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', attrs = [?XMLATTR('type', <<"normal">>)], children = SubjectEls ++ BodyEls}, + Packet = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', attrs = [?XMLATTR(<<"type">>, <<"normal">>)], children = SubjectEls ++ BodyEls}, Sessions = ejabberd_sm:dirty_get_sessions_list(), Local = exmpp_jid:make(Host), lists:foreach( diff --git a/src/mod_caps.erl b/src/mod_caps.erl index 5cd8e274d..9c9518e64 100644 --- a/src/mod_caps.erl +++ b/src/mod_caps.erl @@ -116,9 +116,9 @@ get_features(#caps{node = Node, version = Version, exts = Exts}) -> read_caps(Els) -> read_caps(Els, nothing). read_caps([#xmlel{ns = ?NS_CAPS, name = 'c'} = El | Tail], _Result) -> - Node = exmpp_xml:get_attribute_as_list(El, 'node', ""), - Version = exmpp_xml:get_attribute_as_list(El, 'ver', ""), - Exts = string:tokens(exmpp_xml:get_attribute_as_list(El, 'ext', ""), " "), + Node = exmpp_xml:get_attribute_as_list(El, <<"node">>, ""), + Version = exmpp_xml:get_attribute_as_list(El, <<"ver">>, ""), + Exts = string:tokens(exmpp_xml:get_attribute_as_list(El, <<"ext">>, ""), " "), read_caps(Tail, #caps{node = Node, version = Version, exts = Exts}); read_caps([#xmlel{ns = ?NS_MUC_USER, name = 'x'} | _Tail], _Result) -> nothing; @@ -133,7 +133,7 @@ read_caps([], Result) -> user_send_packet(From, To, #xmlel{name = 'presence', attrs = Attrs, children = Els}) -> case exmpp_jid:bare_compare(From, To) of true -> - Type = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'type', ""), + Type = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"type">>, ""), if Type == ""; Type == "available" -> case read_caps(Els) of nothing -> @@ -158,9 +158,9 @@ caps_stream_features(Acc, MyHost) -> Hash -> [#xmlel{name = c, ns = ?NS_CAPS, - attrs = [?XMLATTR(hash, "sha-1"), - ?XMLATTR(node, ?EJABBERD_URI), - ?XMLATTR(ver, Hash)]} | Acc] + attrs = [?XMLATTR(<<"hash">>, "sha-1"), + ?XMLATTR(<<"node">>, ?EJABBERD_URI), + ?XMLATTR(<<"ver">>, Hash)]} | Acc] end. disco_features(_Acc, From, To, <>, Lang) -> @@ -262,7 +262,7 @@ feature_request(Host, From, Caps, [SubNode | Tail] = SubNodes) -> IQ = #iq{type = get, iq_ns = ?NS_JABBER_CLIENT, payload = #xmlel{ns = ?NS_DISCO_INFO, name = 'query', - attrs = [?XMLATTR('node', Node ++ "#" ++ SubNode)]}}, + attrs = [?XMLATTR(<<"node">>, Node ++ "#" ++ SubNode)]}}, F = fun(IQReply) -> feature_response( IQReply, Host, From, Caps, SubNodes) @@ -279,7 +279,7 @@ feature_response(#iq{type = result, payload = El}, Host, From, Caps, [SubNode | SubNodes]) -> Features = lists:flatmap( fun(#xmlel{name = 'feature', attrs = FAttrs}) -> - [exmpp_xml:get_attribute_from_list_as_list(FAttrs, 'var', "")]; + [exmpp_xml:get_attribute_from_list_as_list(FAttrs, <<"var">>, "")]; (_) -> [] end, El#xmlel.children), @@ -340,10 +340,10 @@ make_my_disco_hash(Host) -> Feats = lists:map( fun({{Feat, _Host}}) -> #xmlel{name = feature, - attrs = [?XMLATTR(var, Feat)]}; + attrs = [?XMLATTR(<<"var">>, Feat)]}; (Feat) -> #xmlel{name = feature, - attrs = [?XMLATTR(var, Feat)]} + attrs = [?XMLATTR(<<"var">>, Feat)]} end, Features), make_disco_hash(Identities ++ Info ++ Feats, sha1); _Err -> @@ -360,7 +360,7 @@ concat_features(Els) -> lists:usort( lists:flatmap( fun(#xmlel{name = feature} = El) -> - [[exmpp_xml:get_attribute(El, var, <<>>), $<]]; + [[exmpp_xml:get_attribute(El, <<"var">>, <<>>), $<]]; (_) -> [] end, Els)). @@ -369,10 +369,10 @@ concat_identities(Els) -> lists:sort( lists:flatmap( fun(#xmlel{name = identity} = El) -> - [[exmpp_xml:get_attribute_as_binary(El, category, <<>>), $/, - exmpp_xml:get_attribute_as_binary(El, type, <<>>), $/, - exmpp_xml:get_attribute_as_binary(El, lang, <<>>), $/, - exmpp_xml:get_attribute_as_binary(El, name, <<>>), $<]]; + [[exmpp_xml:get_attribute_as_binary(El, <<"category">>, <<>>), $/, + exmpp_xml:get_attribute_as_binary(El, <<"type">>, <<>>), $/, + exmpp_xml:get_attribute_as_binary(El, <<"lang">>, <<>>), $/, + exmpp_xml:get_attribute_as_binary(El, <<"name">>, <<>>), $<]]; (_) -> [] end, Els)). @@ -381,7 +381,7 @@ concat_info(Els) -> lists:sort( lists:flatmap( fun(#xmlel{name = x, ns = ?NS_DATA_FORMS, children = Fields} = El) -> - case exmpp_xml:get_attribute_as_list(El, 'type', "") of + case exmpp_xml:get_attribute_as_list(El, <<"type">>, "") of "result" -> [concat_xdata_fields(Fields)]; _ -> @@ -396,7 +396,7 @@ concat_xdata_fields(Fields) -> lists:foldl( fun(#xmlel{name = field, children = Els} = El, [FormType, VarFields] = Acc) -> - case exmpp_xml:get_attribute_as_binary(El, var, <<>>) of + case exmpp_xml:get_attribute_as_binary(El, <<"var">>, <<>>) of <<>> -> Acc; <<"FORM_TYPE">> -> diff --git a/src/mod_configure.erl b/src/mod_configure.erl index 7a863db61..f1fa92cfc 100644 --- a/src/mod_configure.erl +++ b/src/mod_configure.erl @@ -89,24 +89,24 @@ stop(Host) -> -define(INFO_IDENTITY(Category, Type, Name, Lang), [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = - [?XMLATTR('category', Category), - ?XMLATTR('type', Type), - ?XMLATTR('name', ?T(Lang, Name))]}]). + [?XMLATTR(<<"category">>, Category), + ?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"name">>, ?T(Lang, Name))]}]). -define(INFO_COMMAND(Name, Lang), ?INFO_IDENTITY(<<"automation">>, <<"command-node">>, Name, Lang)). -define(NODEJID(To, Name, Node), #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(To)), - ?XMLATTR('name', ?T(Lang, Name)), - ?XMLATTR('node', Node)]}). + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(To)), + ?XMLATTR(<<"name">>, ?T(Lang, Name)), + ?XMLATTR(<<"node">>, Node)]}). -define(NODE(Name, Node), #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = - [?XMLATTR('jid', Server), - ?XMLATTR('name', ?T(Lang, Name)), - ?XMLATTR('node', Node)]}). + [?XMLATTR(<<"jid">>, Server), + ?XMLATTR(<<"name">>, ?T(Lang, Name)), + ?XMLATTR(<<"node">>, Node)]}). -define(NS_ADMINX(Sub), <>). -define(NS_ADMINL(Sub), ["http:","jabber.org","protocol","admin", Sub]). @@ -277,9 +277,9 @@ adhoc_sm_items(Acc, From, To, Lang) -> empty -> [] end, Nodes = [#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(To)), - ?XMLATTR('name', ?T(Lang, "Configuration")), - ?XMLATTR('node', <<"config">>)]}], + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(To)), + ?XMLATTR(<<"name">>, ?T(Lang, "Configuration")), + ?XMLATTR(<<"node">>, <<"config">>)]}], {result, Items ++ Nodes}; _ -> Acc @@ -316,10 +316,10 @@ get_user_resources(BareJID) -> exmpp_jid:prep_domain(BareJID)), lists:map(fun(R) -> #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = - [?XMLATTR('jid', + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary( exmpp_jid:full(BareJID, R))), - ?XMLATTR('name', + ?XMLATTR(<<"name">>, exmpp_jid:prep_node(BareJID))]} end, lists:sort(Rs)). @@ -339,7 +339,7 @@ adhoc_local_items(Acc, From, To, Lang) -> Lang), Nodes1 = lists:filter( fun(N) -> - Nd = exmpp_xml:get_attribute_as_binary(N, 'node', ""), + Nd = exmpp_xml:get_attribute_as_binary(N, <<"node">>, ""), F = get_local_features([], From, To, Nd, Lang), case F of {result, [?NS_ADHOC_s]} -> @@ -370,8 +370,8 @@ recursively_get_local_items(PermLev, LServer, Node, Server, Lang) -> Nodes = lists:flatten( lists:map( fun(N) -> - S = exmpp_xml:get_attribute_as_list(N, 'jid', ""), - Nd = exmpp_xml:get_attribute_as_list(N, 'node', ""), + S = exmpp_xml:get_attribute_as_list(N, <<"jid">>, ""), + Nd = exmpp_xml:get_attribute_as_list(N, <<"node">>, ""), if (S /= Server) or (Nd == "") -> []; true -> @@ -560,8 +560,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('jid', exmpp_jid:to_binary(U, S)), - ?XMLATTR('name', exmpp_jid:to_binary(U, S))]} + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(U, S)), + ?XMLATTR(<<"name">>, exmpp_jid:to_binary(U, S))]} end, Sub) end of {'EXIT', _Reason} -> @@ -653,8 +653,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('jid', exmpp_jid:to_binary(U, S, R)), - ?XMLATTR('name', exmpp_jid:to_binary(U, S))]} + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(U, S, R)), + ?XMLATTR(<<"name">>, exmpp_jid:to_binary(U, S))]} end, SURs) end. @@ -668,8 +668,8 @@ get_all_vh_users(Host) -> N when N =< 100 -> lists:map(fun({S, U}) -> #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(U, S)), - ?XMLATTR('name', exmpp_jid:to_binary(U, S))]} + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(U, S)), + ?XMLATTR(<<"name">>, exmpp_jid:to_binary(U, S))]} end, SUsers); N -> NParts = trunc(math:sqrt(N * 0.618)) + 1, @@ -688,9 +688,9 @@ get_all_vh_users(Host) -> <<(list_to_binary(FU))/binary, "@", (list_to_binary(FS))/binary, " -- ", (list_to_binary(LU))/binary, "@", (list_to_binary(LS))/binary>>, #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = - [?XMLATTR('jid', Host), - ?XMLATTR('node', <<"all users/", Node/binary>>), - ?XMLATTR('name', Name)]} + [?XMLATTR(<<"jid">>, Host), + ?XMLATTR(<<"node">>, <<"all users/", Node/binary>>), + ?XMLATTR(<<"name">>, Name)]} end, lists:seq(1, N, M)) end end. @@ -706,9 +706,9 @@ get_outgoing_s2s(Host, Lang) -> lists:map( fun(T) -> #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = - [?XMLATTR('jid', Host), - ?XMLATTR('node', <<"outgoing s2s/", (list_to_binary(T))/binary>>), - ?XMLATTR('name', + [?XMLATTR(<<"jid">>, Host), + ?XMLATTR(<<"node">>, <<"outgoing s2s/", (list_to_binary(T))/binary>>), + ?XMLATTR(<<"name">>, io_lib:format(?T(Lang, "To ~s"), [T]))]} end, lists:usort(TConns)) end. @@ -721,9 +721,9 @@ get_outgoing_s2s(Host, Lang, To) -> lists:map( fun({F, _T}) -> #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = - [?XMLATTR('jid', Host), - ?XMLATTR('node', <<"outgoing s2s/", (list_to_binary(To))/binary, "/", (list_to_binary(F))/binary>>), - ?XMLATTR('name', + [?XMLATTR(<<"jid">>, Host), + ?XMLATTR(<<"node">>, <<"outgoing s2s/", (list_to_binary(To))/binary, "/", (list_to_binary(F))/binary>>), + ?XMLATTR(<<"name">>, io_lib:format(?T(Lang, "From ~s"), [F]))]} end, lists:keysort(1, lists:filter(fun(E) -> element(2, E) == To @@ -740,9 +740,9 @@ get_running_nodes(Server, _Lang) -> fun(N) -> S = list_to_binary(atom_to_list(N)), #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = - [?XMLATTR('jid', Server), - ?XMLATTR('node', <<"running nodes/", S/binary>>), - ?XMLATTR('name', S)]} + [?XMLATTR(<<"jid">>, Server), + ?XMLATTR(<<"node">>, <<"running nodes/", S/binary>>), + ?XMLATTR(<<"name">>, S)]} end, lists:sort(DBNodes)) end. @@ -757,9 +757,9 @@ get_stopped_nodes(_Lang) -> fun(N) -> S = list_to_binary(atom_to_list(N)), #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = - [?XMLATTR('jid', ?MYNAME), - ?XMLATTR('node', <<"stopped nodes/", S/binary>>), - ?XMLATTR('name', S)]} + [?XMLATTR(<<"jid">>, ?MYNAME), + ?XMLATTR(<<"node">>, <<"stopped nodes/", S/binary>>), + ?XMLATTR(<<"name">>, S)]} end, lists:sort(DBNodes)) end. @@ -858,45 +858,45 @@ adhoc_local_commands(From, To, -define(TVFIELD(Type, Var, Val), - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type), - ?XMLATTR('var', Var)], + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"var">>, Var)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = Val}]}]}). -define(HFIELD(), ?TVFIELD(<<"hidden">>, <<"FORM_TYPE">>, list_to_binary(?NS_ADMIN_s))). -define(TLFIELD(Type, Label, Var), - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type), - ?XMLATTR('label', ?T(Lang, Label)), - ?XMLATTR('var', Var)]}). + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"label">>, ?T(Lang, Label)), + ?XMLATTR(<<"var">>, Var)]}). -define(XFIELD(Type, Label, Var, Val), - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type), - ?XMLATTR('label', ?T(Lang, Label)), - ?XMLATTR('var', Var)], + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"label">>, ?T(Lang, Label)), + ?XMLATTR(<<"var">>, Var)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = Val}]}]}). -define(XMFIELD(Type, Label, Var, Vals), - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type), - ?XMLATTR('label', ?T(Lang, Label)), - ?XMLATTR('var', Var)], + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"label">>, ?T(Lang, Label)), + ?XMLATTR(<<"var">>, Var)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Val)}]} || Val <- Vals]}). -define(TABLEFIELD(Table, Val), - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', <<"list-single">>), - ?XMLATTR('label', Table), - ?XMLATTR('var', Table)], + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"type">>, <<"list-single">>), + ?XMLATTR(<<"label">>, Table), + ?XMLATTR(<<"var">>, Table)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(atom_to_list(Val))}]}, - #xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [?XMLATTR('label', + #xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [?XMLATTR(<<"label">>, ?T(Lang, "RAM copy"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"ram_copies">>}]}]}, - #xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [?XMLATTR('label', + #xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [?XMLATTR(<<"label">>, ?T(Lang, "RAM and disc copy"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"disc_copies">>}]}]}, - #xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [?XMLATTR('label', + #xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [?XMLATTR(<<"label">>, ?T(Lang, "Disc only copy"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"disc_only_copies">>}]}]}, - #xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [?XMLATTR('label', + #xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = [?XMLATTR(<<"label">>, ?T(Lang, "Remote copy"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"unknown">>}]}]} ]}). @@ -1057,7 +1057,7 @@ get_form(_Host, ["running nodes", _ENode, "restart"], Lang) -> Make_option = fun(LabelNum, LabelUnit, Value)-> #xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = - [?XMLATTR('label', LabelNum ++ ?T(Lang, LabelUnit))], children = + [?XMLATTR(<<"label">>, LabelNum ++ ?T(Lang, LabelUnit))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Value)}]}]} end, {result, [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', children = @@ -1065,9 +1065,9 @@ get_form(_Host, ["running nodes", _ENode, "restart"], Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(?T(Lang, "Restart Service"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"list-single">>), - ?XMLATTR('label', ?T(Lang, "Time delay")), - ?XMLATTR('var', <<"delay">>)], children = + [?XMLATTR(<<"type">>, <<"list-single">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Time delay")), + ?XMLATTR(<<"var">>, <<"delay">>)], children = [Make_option("", "immediately", "1"), Make_option("15 ", "seconds", "15"), Make_option("30 ", "seconds", "30"), @@ -1083,23 +1083,23 @@ get_form(_Host, ["running nodes", _ENode, "restart"], Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'required'} ]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"fixed">>), - ?XMLATTR('label', ?T(Lang, "Send announcement to all online users on all hosts"))]}, + [?XMLATTR(<<"type">>, <<"fixed">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Send announcement to all online users on all hosts"))]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"subject">>), - ?XMLATTR('type', <<"text-single">>), - ?XMLATTR('label', ?T(Lang, "Subject"))]}, + [?XMLATTR(<<"var">>, <<"subject">>), + ?XMLATTR(<<"type">>, <<"text-single">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Subject"))]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"announcement">>), - ?XMLATTR('type', <<"text-multi">>), - ?XMLATTR('label', ?T(Lang, "Message body"))]} + [?XMLATTR(<<"var">>, <<"announcement">>), + ?XMLATTR(<<"type">>, <<"text-multi">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Message body"))]} ]}]}; get_form(_Host, ["running nodes", _ENode, "shutdown"], Lang) -> Make_option = fun(LabelNum, LabelUnit, Value)-> #xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = - [?XMLATTR('label', LabelNum ++ ?T(Lang, LabelUnit))], children = + [?XMLATTR(<<"label">>, LabelNum ++ ?T(Lang, LabelUnit))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Value)}]}]} end, {result, [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', children = @@ -1107,9 +1107,9 @@ get_form(_Host, ["running nodes", _ENode, "shutdown"], Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(?T(Lang, "Shut Down Service"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"list-single">>), - ?XMLATTR('label', ?T(Lang, "Time delay")), - ?XMLATTR('var', <<"delay">>)], children = + [?XMLATTR(<<"type">>, <<"list-single">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Time delay")), + ?XMLATTR(<<"var">>, <<"delay">>)], children = [Make_option("", "immediately", "1"), Make_option("15 ", "seconds", "15"), Make_option("30 ", "seconds", "30"), @@ -1125,16 +1125,16 @@ get_form(_Host, ["running nodes", _ENode, "shutdown"], Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'required'} ]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"fixed">>), - ?XMLATTR('label', ?T(Lang, "Send announcement to all online users on all hosts"))]}, + [?XMLATTR(<<"type">>, <<"fixed">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Send announcement to all online users on all hosts"))]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"subject">>), - ?XMLATTR('type', <<"text-single">>), - ?XMLATTR('label', ?T(Lang, "Subject"))]}, + [?XMLATTR(<<"var">>, <<"subject">>), + ?XMLATTR(<<"type">>, <<"text-single">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Subject"))]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"announcement">>), - ?XMLATTR('type', <<"text-multi">>), - ?XMLATTR('label', ?T(Lang, "Message body"))]} + [?XMLATTR(<<"var">>, <<"announcement">>), + ?XMLATTR(<<"type">>, <<"text-multi">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Message body"))]} ]}]}; get_form(Host, ["config", "acls"], Lang) -> @@ -1144,11 +1144,11 @@ get_form(Host, ["config", "acls"], Lang) -> [#xmlcdata{cdata = list_to_binary(?T( Lang, "Access Control List Configuration"))}]}, - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', <<"text-multi">>), - ?XMLATTR('label', + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"type">>, <<"text-multi">>), + ?XMLATTR(<<"label">>, ?T( Lang, "Access control lists")), - ?XMLATTR('var', <<"acls">>)], + ?XMLATTR(<<"var">>, <<"acls">>)], children = lists:map(fun(S) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(S)}]} end, @@ -1172,11 +1172,11 @@ get_form(Host, ["config", "access"], Lang) -> [#xmlcdata{cdata = list_to_binary(?T( Lang, "Access Configuration"))}]}, - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =[?XMLATTR('type', <<"text-multi">>), - ?XMLATTR('label', + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs =[?XMLATTR(<<"type">>, <<"text-multi">>), + ?XMLATTR(<<"label">>, ?T( Lang, "Access rules")), - ?XMLATTR('var', <<"access">>)], + ?XMLATTR(<<"var">>, <<"access">>)], children = lists:map(fun(S) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'value', children =[#xmlcdata{cdata = list_to_binary(S)}]} end, @@ -1199,19 +1199,19 @@ get_form(_Host, ?NS_ADMINL("add-user"), Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(?T(Lang, "Add User"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"jid-single">>), - ?XMLATTR('label', ?T(Lang, "Jabber ID")), - ?XMLATTR('var', <<"accountjid">>)], children = + [?XMLATTR(<<"type">>, <<"jid-single">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Jabber ID")), + ?XMLATTR(<<"var">>, <<"accountjid">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"text-private">>), - ?XMLATTR('label', ?T(Lang, "Password")), - ?XMLATTR('var', <<"password">>)], children = + [?XMLATTR(<<"type">>, <<"text-private">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Password")), + ?XMLATTR(<<"var">>, <<"password">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"text-private">>), - ?XMLATTR('label', ?T(Lang, "Password Verification")), - ?XMLATTR('var', <<"password-verify">>)], children = + [?XMLATTR(<<"type">>, <<"text-private">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Password Verification")), + ?XMLATTR(<<"var">>, <<"password-verify">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]} ]}]}; @@ -1221,9 +1221,9 @@ get_form(_Host, ?NS_ADMINL("delete-user"), Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(?T(Lang, "Delete User"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"jid-multi">>), - ?XMLATTR('label', ?T(Lang, "Jabber ID")), - ?XMLATTR('var', <<"accountjids">>)], children = + [?XMLATTR(<<"type">>, <<"jid-multi">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Jabber ID")), + ?XMLATTR(<<"var">>, <<"accountjids">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]} ]}]}; @@ -1233,9 +1233,9 @@ get_form(_Host, ?NS_ADMINL("end-user-session"), Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(?T(Lang, "End User Session"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"jid-single">>), - ?XMLATTR('label', ?T(Lang, "Jabber ID")), - ?XMLATTR('var', <<"accountjid">>)], children = + [?XMLATTR(<<"type">>, <<"jid-single">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Jabber ID")), + ?XMLATTR(<<"var">>, <<"accountjid">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]} ]}]}; @@ -1245,9 +1245,9 @@ get_form(_Host, ?NS_ADMINL("get-user-password"), Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(?T(Lang, "Get User Password"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"jid-single">>), - ?XMLATTR('label', ?T(Lang, "Jabber ID")), - ?XMLATTR('var', <<"accountjid">>)], children = + [?XMLATTR(<<"type">>, <<"jid-single">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Jabber ID")), + ?XMLATTR(<<"var">>, <<"accountjid">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]} ]}]}; @@ -1257,14 +1257,14 @@ get_form(_Host, ?NS_ADMINL("change-user-password"), Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(?T(Lang, "Get User Password"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"jid-single">>), - ?XMLATTR('label', ?T(Lang, "Jabber ID")), - ?XMLATTR('var', <<"accountjid">>)], children = + [?XMLATTR(<<"type">>, <<"jid-single">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Jabber ID")), + ?XMLATTR(<<"var">>, <<"accountjid">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"text-private">>), - ?XMLATTR('label', ?T(Lang, "Password")), - ?XMLATTR('var', <<"password">>)], children = + [?XMLATTR(<<"type">>, <<"text-private">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Password")), + ?XMLATTR(<<"var">>, <<"password">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]} ]}]}; @@ -1274,9 +1274,9 @@ get_form(_Host, ?NS_ADMINL("get-user-lastlogin"), Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(?T(Lang, "Get User Last Login Time"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"jid-single">>), - ?XMLATTR('label', ?T(Lang, "Jabber ID")), - ?XMLATTR('var', <<"accountjid">>)], children = + [?XMLATTR(<<"type">>, <<"jid-single">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Jabber ID")), + ?XMLATTR(<<"var">>, <<"accountjid">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]} ]}]}; @@ -1286,9 +1286,9 @@ get_form(_Host, ?NS_ADMINL("user-stats"), Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(?T(Lang, "Get User Statistics"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"jid-single">>), - ?XMLATTR('label', ?T(Lang, "Jabber ID")), - ?XMLATTR('var', <<"accountjid">>)], children = + [?XMLATTR(<<"type">>, <<"jid-single">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Jabber ID")), + ?XMLATTR(<<"var">>, <<"accountjid">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]} ]}]}; @@ -1298,9 +1298,9 @@ get_form(Host, ?NS_ADMINL("get-registered-users-num"), Lang) -> [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', children = [?HFIELD(), #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"text-single">>), - ?XMLATTR('label', ?T(Lang, "Number of registered users")), - ?XMLATTR('var', <<"registeredusersnum">>)], children = + [?XMLATTR(<<"type">>, <<"text-single">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Number of registered users")), + ?XMLATTR(<<"var">>, <<"registeredusersnum">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Num)}]}] }]}]}; @@ -1310,9 +1310,9 @@ get_form(Host, ?NS_ADMINL("get-online-users-num"), Lang) -> [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', children = [?HFIELD(), #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"text-single">>), - ?XMLATTR('label', ?T(Lang, "Number of online users")), - ?XMLATTR('var', <<"onlineusersnum">>)], children = + [?XMLATTR(<<"type">>, <<"text-single">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Number of online users")), + ?XMLATTR(<<"var">>, <<"onlineusersnum">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Num)}]}] }]}]}; @@ -1688,7 +1688,7 @@ set_form(From, Host, ?NS_ADMINL("get-user-lastlogin"), Lang, XData) -> _ -> ?T(Lang, "Online") end, - {result, [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR('type', <<"result">>)], children = + {result, [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR(<<"type">>, <<"result">>)], children = [?HFIELD(), ?XFIELD(<<"jid-single">>, "Jabber ID", <<"accountjid">>, list_to_binary(AccountString)), ?XFIELD(<<"text-single">>, "Last login", <<"lastlogin">>, list_to_binary(FLast)) @@ -1748,12 +1748,12 @@ stop_node(From, Host, ENode, Action, XData) -> Delay = list_to_integer(get_value("delay", XData)), Subject = case get_value("subject", XData) of [] -> []; - S -> [#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('var', <<"subject">>)], children = + S -> [#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"var">>, <<"subject">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(S)}]}]}] end, Announcement = case get_values("announcement", XData) of [] -> []; - As -> [#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('var', <<"body">>)], children = + As -> [#xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"var">>, <<"body">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Line)}]} || Line <- As] }] end, case Subject ++ Announcement of @@ -1763,10 +1763,10 @@ stop_node(From, Host, ENode, Action, XData) -> node = binary_to_list(?NS_ADMINX(<<"announce-allhosts">>)), action = "complete", xdata = #xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = - [?XMLATTR('type', <<"submit">>)], children = + [?XMLATTR(<<"type">>, <<"submit">>)], children = SubEls}, others= [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = - [?XMLATTR('type', <<"submit">>)], children = + [?XMLATTR(<<"type">>, <<"submit">>)], children = SubEls}] }, To = exmpp_jid:make(Host), @@ -1845,15 +1845,15 @@ get_sm_form(User, Server, "config", Lang) -> list_to_binary(?T( Lang, "Administration of ") ++ User)}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('type', <<"list-single">>), - ?XMLATTR('label', ?T(Lang, "Action on user")), - ?XMLATTR('var', <<"action">>)], children = + [?XMLATTR(<<"type">>, <<"list-single">>), + ?XMLATTR(<<"label">>, ?T(Lang, "Action on user")), + ?XMLATTR(<<"var">>, <<"action">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"edit">>}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = - [?XMLATTR('label', ?T(Lang, "Edit Properties"))], children = + [?XMLATTR(<<"label">>, ?T(Lang, "Edit Properties"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"edit">>}]}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'option', attrs = - [?XMLATTR('label', ?T(Lang, "Remove User"))], children = + [?XMLATTR(<<"label">>, ?T(Lang, "Remove User"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"remove">>}]}]} ]}, ?XFIELD(<<"text-private">>, "Password", <<"password">>, diff --git a/src/mod_configure2.erl b/src/mod_configure2.erl index 7fff861e6..c38a1b408 100644 --- a/src/mod_configure2.erl +++ b/src/mod_configure2.erl @@ -124,15 +124,15 @@ process_local_iq(From, To, #iq{type = Type, payload = Request} = IQ_Rec) -> process_get(#xmlel{ns = ?NS_ECONFIGURE, name = 'info'}) -> S2SConns = ejabberd_s2s:dirty_get_connections(), TConns = lists:usort([element(2, C) || C <- S2SConns]), - Attrs = [?XMLATTR('registered-users', mnesia:table_info(passwd, size)), - ?XMLATTR('online-users', mnesia:table_info(presence, size)), - ?XMLATTR('running-nodes', + Attrs = [?XMLATTR(<<"registered-users">>, mnesia:table_info(passwd, size)), + ?XMLATTR(<<"online-users">>, mnesia:table_info(presence, size)), + ?XMLATTR(<<"running-nodes">>, length(mnesia:system_info(running_db_nodes))), - ?XMLATTR('stopped-nodes', + ?XMLATTR(<<"stopped-nodes">>, length(lists:usort(mnesia:system_info(db_nodes) ++ mnesia:system_info(extra_db_nodes)) -- mnesia:system_info(running_db_nodes))), - ?XMLATTR('outgoing-s2s-servers', + ?XMLATTR(<<"outgoing-s2s-servers">>, length(TConns))], {result, #xmlel{ns = ?NS_ECONFIGURE, name = 'info', attrs = Attrs}}; process_get(#xmlel{ns = ?NS_ECONFIGURE, name = 'welcome-message', attrs = Attrs}) -> diff --git a/src/mod_disco.erl b/src/mod_disco.erl index 97d8f492f..5bf9e5481 100644 --- a/src/mod_disco.erl +++ b/src/mod_disco.erl @@ -124,14 +124,14 @@ unregister_extra_domain(HostB, Domain) when is_binary(HostB) -> process_local_iq_items(From, To, #iq{type = get, payload = SubEl, lang = Lang} = IQ_Rec) -> - Node = exmpp_xml:get_attribute_as_binary(SubEl, 'node', <<>>), + Node = exmpp_xml:get_attribute_as_binary(SubEl, <<"node">>, <<>>), Host = exmpp_jid:prep_domain(To), case find_items(disco_local_items, Host, From, To, Node, Lang) of {result, Items} -> ANode = case Node of <<>> -> []; - _ -> [?XMLATTR('node', Node)] + _ -> [?XMLATTR(<<"node">>, Node)] end, Result = #xmlel{ns = ?NS_DISCO_ITEMS, name = 'query', attrs = ANode, children = Items}, @@ -145,7 +145,7 @@ process_local_iq_items(_From, _To, #iq{type = set} = IQ_Rec) -> process_local_iq_info(From, To, #iq{type = get, payload = SubEl, lang = Lang} = IQ_Rec) -> - Node = exmpp_xml:get_attribute_as_binary(SubEl, 'node', <<>>), + Node = exmpp_xml:get_attribute_as_binary(SubEl, <<"node">>, <<>>), HostB = exmpp_jid:prep_domain(To), Identity = ejabberd_hooks:run_fold(disco_local_identity, HostB, @@ -158,7 +158,7 @@ process_local_iq_info(From, To, #iq{type = get, payload = SubEl, {result, Features} -> ANode = case Node of <<>> -> []; - _ -> [?XMLATTR('node', Node)] + _ -> [?XMLATTR(<<"node">>, Node)] end, Result = #xmlel{ns = ?NS_DISCO_INFO, name = 'query', attrs = ANode, @@ -172,9 +172,9 @@ process_local_iq_info(_From, _To, #iq{type = set} = IQ_Rec) -> get_local_identity(Acc, _From, _To, <<>>, _Lang) -> Acc ++ [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = [ - ?XMLATTR('category', <<"server">>), - ?XMLATTR('type', <<"im">>), - ?XMLATTR('name', <<"ejabberd">>) + ?XMLATTR(<<"category">>, <<"server">>), + ?XMLATTR(<<"type">>, <<"im">>), + ?XMLATTR(<<"name">>, <<"ejabberd">>) ]}]; get_local_identity(Acc, _From, _To, _Node, _Lang) -> @@ -208,7 +208,7 @@ get_local_features(Acc, _From, _To, _Node, _Lang) -> features_to_xml(FeatureList) -> %% Avoid duplicating features [#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', - attrs = [?XMLATTR('var', Feat)]} || + attrs = [?XMLATTR(<<"var">>, Feat)]} || Feat <- lists:usort( lists:map( fun({{Feature, _Host}}) -> @@ -228,7 +228,7 @@ domain_to_xml({Domain}) -> domain_to_xml(Domain); domain_to_xml(Domain) when is_binary(Domain)-> #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [ - ?XMLATTR('jid', Domain) + ?XMLATTR(<<"jid">>, Domain) ]}; domain_to_xml(Domain) when is_list(Domain) -> domain_to_xml(list_to_binary(Domain)). @@ -284,13 +284,13 @@ get_vh_services(Host) -> process_sm_iq_items(From, To, #iq{type = get, payload = SubEl, lang = Lang} = IQ_Rec) -> - Node = exmpp_xml:get_attribute_as_binary(SubEl, 'node', <<>>), + Node = exmpp_xml:get_attribute_as_binary(SubEl, <<"node">>, <<>>), Host = exmpp_jid:prep_domain(To), case find_items(disco_sm_items, Host, From, To, Node, Lang) of {result, Items} -> ANode = case Node of <<>> -> []; - _ -> [?XMLATTR('node', Node)] + _ -> [?XMLATTR(<<"node">>, Node)] end, AItems = case Node of <<>> -> @@ -362,7 +362,7 @@ process_sm_iq_info(From, To, #iq{type = get, payload = SubEl, lang = Lang} = IQ_Rec) -> case is_presence_subscribed(From, To) of true -> - Node = exmpp_xml:get_attribute_as_binary(SubEl, 'node', <<>>), + Node = exmpp_xml:get_attribute_as_binary(SubEl, <<"node">>, <<>>), Identity = ejabberd_hooks:run_fold(disco_sm_identity, exmpp_jid:prep_domain(To), [], @@ -372,7 +372,7 @@ process_sm_iq_info(From, To, #iq{type = get, payload = SubEl, {result, Features} -> ANode = case Node of <<>> -> []; - _ -> [?XMLATTR('node', Node)] + _ -> [?XMLATTR(<<"node">>, Node)] end, Result = #xmlel{ns = ?NS_DISCO_INFO, name = 'query', attrs = ANode, @@ -421,9 +421,9 @@ get_user_resources(JID) -> exmpp_jid:prep_domain(JID)), lists:map(fun(R) -> #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [ - ?XMLATTR('jid', + ?XMLATTR(<<"jid">>, exmpp_jid:to_binary(exmpp_jid:full(JID, R))), - ?XMLATTR('name', exmpp_jid:prep_node(JID)) + ?XMLATTR(<<"name">>, exmpp_jid:prep_node(JID)) ]} end, lists:sort(Rs)). @@ -440,13 +440,13 @@ get_info(Acc, Host, Mod, Node, _Lang) when Node == <<>> -> CData1 = #xmlcdata{cdata = list_to_binary(?NS_SERVERINFO_s)}, Value1 = #xmlel{name = 'value', children = [CData1]}, Field1 = #xmlel{name = 'field', - attrs = [?XMLATTR('type', <<"hidden">>), - ?XMLATTR('var', <<"FORM_TYPE">>)], + attrs = [?XMLATTR(<<"type">>, <<"hidden">>), + ?XMLATTR(<<"var">>, <<"FORM_TYPE">>)], children = [Value1] }, X = #xmlel{name = 'x', ns = ?NS_DATA_FORMS, - attrs = [?XMLATTR('type', <<"result">>)], + attrs = [?XMLATTR(<<"type">>, <<"result">>)], children = [Field1 | Serverinfo_fields] }, [X | Acc]; @@ -475,7 +475,7 @@ fields_to_xml(Fields) -> field_to_xml({_, Var, Values}) -> Values_xml = values_to_xml(Values), #xmlel{name = 'field', - attrs = [?XMLATTR('var', list_to_binary(Var))], + attrs = [?XMLATTR(<<"var">>, list_to_binary(Var))], children = Values_xml }. diff --git a/src/mod_last.erl b/src/mod_last.erl index e091e6269..8040e797b 100644 --- a/src/mod_last.erl +++ b/src/mod_last.erl @@ -113,7 +113,7 @@ stop(Host) -> process_local_iq(_From, _To, #iq{type = get} = IQ_Rec) -> Sec = get_node_uptime(), Response = #xmlel{ns = ?NS_LAST_ACTIVITY, name = 'query', attrs = - [?XMLATTR('seconds', Sec)]}, + [?XMLATTR(<<"seconds">>, Sec)]}, exmpp_iq:result(IQ_Rec, Response); process_local_iq(_From, _To, #iq{type = set} = IQ_Rec) -> exmpp_iq:error(IQ_Rec, 'not-allowed'). @@ -186,7 +186,7 @@ get_last_iq(IQ_Rec, LUser, LServer) -> _ -> Sec = 0, #xmlel{ns = ?NS_LAST_ACTIVITY, name = 'query', - attrs = [?XMLATTR('seconds', Sec)]} + attrs = [?XMLATTR(<<"seconds">>, Sec)]} end. get_last_iq_disconnected(IQ_Rec, LUser, LServer) -> @@ -199,7 +199,7 @@ get_last_iq_disconnected(IQ_Rec, LUser, LServer) -> TimeStamp2 = now_to_seconds(now()), Sec = TimeStamp2 - TimeStamp, Response = #xmlel{ns = ?NS_LAST_ACTIVITY, name = 'query', - attrs = [?XMLATTR('seconds', Sec)], + attrs = [?XMLATTR(<<"seconds">>, Sec)], children = [#xmlcdata{cdata = Status}]}, exmpp_iq:result(IQ_Rec, Response) end. diff --git a/src/mod_last_odbc.erl b/src/mod_last_odbc.erl index 5bb98aa04..975abe430 100644 --- a/src/mod_last_odbc.erl +++ b/src/mod_last_odbc.erl @@ -71,7 +71,7 @@ stop(Host) -> process_local_iq(_From, _To, #iq{type = get} = IQ_Rec) -> Sec = get_node_uptime(), Response = #xmlel{ns = ?NS_LAST_ACTIVITY, name = 'query', attrs = - [?XMLATTR('seconds', Sec)]}, + [?XMLATTR(<<"seconds">>, Sec)]}, exmpp_iq:result(IQ_Rec, Response); process_local_iq(_From, _To, #iq{type = set} = IQ_Rec) -> exmpp_iq:error(IQ_Rec, 'not-allowed'). @@ -137,7 +137,7 @@ get_last(IQ_Rec, LUser, LServer) -> TimeStamp2 = now_to_seconds(now()), Sec = TimeStamp2 - TimeStamp, Response = #xmlel{ns = ?NS_LAST_ACTIVITY, name = 'query', - attrs = [?XMLATTR('seconds', Sec)], + attrs = [?XMLATTR(<<"seconds">>, Sec)], children = [#xmlcdata{cdata = list_to_binary(Status)}]}, exmpp_iq:result(IQ_Rec, Response); _ -> diff --git a/src/mod_muc/mod_muc.erl b/src/mod_muc/mod_muc.erl index b70a42539..5e8e25dd3 100644 --- a/src/mod_muc/mod_muc.erl +++ b/src/mod_muc/mod_muc.erl @@ -524,7 +524,7 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper, ejabberd_router:route(To, From, Err) end; 'message' -> - case exmpp_xml:get_attribute_as_list(Packet,type, "chat") of + case exmpp_xml:get_attribute_as_list(Packet,<<"type">>, "chat") of "error" -> ok; _ -> @@ -676,32 +676,32 @@ register_room(Host, Room, Pid) -> iq_disco_info(Lang) -> [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', - attrs = [?XMLATTR('category', + attrs = [?XMLATTR(<<"category">>, <<"conference">>), - ?XMLATTR('type', + ?XMLATTR(<<"type">>, <<"text">>), - ?XMLATTR('name', + ?XMLATTR(<<"name">>, translate:translate(Lang, "Rooms"))]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = - [?XMLATTR('var', + [?XMLATTR(<<"var">>, ?NS_DISCO_INFO_s)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = - [?XMLATTR('var', + [?XMLATTR(<<"var">>, ?NS_DISCO_ITEMS_s)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = - [?XMLATTR('var', + [?XMLATTR(<<"var">>, ?NS_MUC_s)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = - [?XMLATTR('var', + [?XMLATTR(<<"var">>, ?NS_MUC_UNIQUE_s)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = - [?XMLATTR('var', + [?XMLATTR(<<"var">>, ?NS_INBAND_REGISTER_s)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = - [?XMLATTR('var', + [?XMLATTR(<<"var">>, ?NS_RSM_s)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = - [?XMLATTR('var', + [?XMLATTR(<<"var">>, ?NS_VCARD_s)]}]. @@ -730,9 +730,9 @@ iq_disco_items(Host, From, Lang, Rsm) -> flush(), {true, #xmlel{name = 'item', - attrs = [?XMLATTR('jid', + attrs = [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(exmpp_jid:make(Name, Host))), - ?XMLATTR('name', + ?XMLATTR(<<"name">>, Desc)]}}; _ -> false @@ -808,10 +808,10 @@ flush() -> -define(XFIELD(Type, Label, Var, Val), #xmlel{name = "field", - attrs = [?XMLATTR('type', Type), - ?XMLATTR('label', + attrs = [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"label">>, translate:translate(Lang, Label)), - ?XMLATTR('var', Var)], + ?XMLATTR(<<"var">>, Var)], children = [#xmlel{name = 'value', children = [#xmlcdata{cdata = Val}]}]}). diff --git a/src/mod_muc/mod_muc_room.erl b/src/mod_muc/mod_muc_room.erl index 63105fab0..8bc8bdb31 100644 --- a/src/mod_muc/mod_muc_room.erl +++ b/src/mod_muc/mod_muc_room.erl @@ -578,7 +578,7 @@ normal_state(_Event, StateData) -> %%---------------------------------------------------------------------- handle_event({service_message, Msg}, _StateName, StateData) -> MessagePkt = #xmlel{name = 'message', - attrs = [?XMLATTR('type', <<"groupchat">>)], + attrs = [?XMLATTR(<<"type">>, <<"groupchat">>)], children = [#xmlel{name = 'body', children = [#xmlcdata{cdata = Msg}]}]}, send_multiple( @@ -757,16 +757,16 @@ terminate(Reason, _StateName, StateData) -> _ -> <<"Room terminates">> end, ReasonEl = #xmlel{name = 'reason', children = [#xmlcdata{cdata = ReasonT}]}, - ItemAttrs = [?XMLATTR('affiliation', <<"none">>), - ?XMLATTR('role', <<"none">>)], + ItemAttrs = [?XMLATTR(<<"affiliation">>, <<"none">>), + ?XMLATTR(<<"role">>, <<"none">>)], XEls = [#xmlel{ns = ?NS_MUC_USER, name = 'item', attrs = ItemAttrs, children = [ReasonEl]}, #xmlel{ns = ?NS_MUC_USER, name = 'status', - attrs = [?XMLATTR('code', <<"332">>)]}], + attrs = [?XMLATTR(<<"code">>, <<"332">>)]}], Packet = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', - attrs = [?XMLATTR('type', <<"unavailable">>)], + attrs = [?XMLATTR(<<"type">>, <<"unavailable">>)], children = [#xmlel{ns = ?NS_MUC_USER, name = 'x', children = XEls} ]}, @@ -1643,7 +1643,7 @@ add_new_user(From, Nick, Packet, StateData) -> if not (NewState#state.config)#config.anonymous -> WPacket = #xmlel{name = 'message', - attrs = [?XMLATTR('type', <<"groupchat">>)], + attrs = [?XMLATTR(<<"type">>, <<"groupchat">>)], children = [ #xmlel{name = 'body', children = [#xmlcdata{cdata = @@ -1693,7 +1693,7 @@ add_new_user(From, Nick, Packet, StateData) -> SID, RoomJID, To, Lang, From) of {ok, ID, CaptchaEls} -> MsgPkt = #xmlel{name = 'message', - attrs = [#xmlattr{name = 'id', value = list_to_binary(ID)}], + attrs = [#xmlattr{name = <<"id">>, value = list_to_binary(ID)}], children = CaptchaEls}, Robots = ?DICT:store(From, {Nick, Packet}, StateData#state.robots), @@ -1933,12 +1933,12 @@ send_new_presence(NJID, Reason, StateData) -> case (Info#user.role == moderator) orelse ((StateData#state.config)#config.anonymous == false) of true -> - [?XMLATTR('jid', exmpp_jid:to_binary(RealJID)), - ?XMLATTR('affiliation', SAffiliation), - ?XMLATTR('role', SRole)]; + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(RealJID)), + ?XMLATTR(<<"affiliation">>, SAffiliation), + ?XMLATTR(<<"role">>, SRole)]; _ -> - [?XMLATTR('affiliation', SAffiliation), - ?XMLATTR('role', SRole)] + [?XMLATTR(<<"affiliation">>, SAffiliation), + ?XMLATTR(<<"role">>, SRole)] end, ItemEls = case Reason of <<>> -> @@ -1950,7 +1950,7 @@ send_new_presence(NJID, Reason, StateData) -> Status = case StateData#state.just_created of true -> [#xmlel{name = 'status', - attrs = [?XMLATTR('code', <<"201">>)]}]; + attrs = [?XMLATTR(<<"code">>, <<"201">>)]}]; false -> [] end, @@ -1958,7 +1958,7 @@ send_new_presence(NJID, Reason, StateData) -> andalso (NJID == Info#user.jid) of true -> [#xmlel{name = 'status', - attrs = [?XMLATTR('code', <<"100">>)]} + attrs = [?XMLATTR(<<"code">>, <<"100">>)]} | Status]; false -> Status @@ -1998,14 +1998,14 @@ send_existing_presences(ToJID, StateData) -> ((StateData#state.config)#config.anonymous == false) of true -> - [?XMLATTR('jid', exmpp_jid:to_binary(FromJID)), - ?XMLATTR('affiliation', + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(FromJID)), + ?XMLATTR(<<"affiliation">>, affiliation_to_binary(FromAffiliation)), - ?XMLATTR('role', role_to_binary(FromRole))]; + ?XMLATTR(<<"role">>, role_to_binary(FromRole))]; _ -> - [?XMLATTR('affiliation', + [?XMLATTR(<<"affiliation">>, affiliation_to_binary(FromAffiliation)), - ?XMLATTR('role', role_to_binary(FromRole))] + ?XMLATTR(<<"role">>, role_to_binary(FromRole))] end, Packet = exmpp_xml:append_child(Presence, #xmlel{ns = ?NS_MUC_USER, name = 'x', @@ -2055,36 +2055,36 @@ send_nick_changing(JID, OldNick, StateData) -> case (Info#user.role == moderator) orelse ((StateData#state.config)#config.anonymous == false) of true -> - [?XMLATTR('jid', exmpp_jid:to_binary(RealJID)), - ?XMLATTR('affiliation', SAffiliation), - ?XMLATTR('role', SRole), - ?XMLATTR('nick', Nick)]; + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(RealJID)), + ?XMLATTR(<<"affiliation">>, SAffiliation), + ?XMLATTR(<<"role">>, SRole), + ?XMLATTR(<<"nick">>, Nick)]; _ -> - [?XMLATTR('affiliation', SAffiliation), - ?XMLATTR('role', SRole), - ?XMLATTR('nick', Nick)] + [?XMLATTR(<<"affiliation">>, SAffiliation), + ?XMLATTR(<<"role">>, SRole), + ?XMLATTR(<<"nick">>, Nick)] end, ItemAttrs2 = case (Info#user.role == moderator) orelse ((StateData#state.config)#config.anonymous == false) of true -> - [?XMLATTR('jid', exmpp_jid:to_binary(RealJID)), - ?XMLATTR('affiliation', SAffiliation), - ?XMLATTR('role', SRole)]; + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(RealJID)), + ?XMLATTR(<<"affiliation">>, SAffiliation), + ?XMLATTR(<<"role">>, SRole)]; _ -> - [?XMLATTR('affiliation', SAffiliation), - ?XMLATTR('role', SRole)] + [?XMLATTR(<<"affiliation">>, SAffiliation), + ?XMLATTR(<<"role">>, SRole)] end, Packet1 = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', - attrs = [?XMLATTR('type', <<"unavailable">>)], + attrs = [?XMLATTR(<<"type">>, <<"unavailable">>)], children = [#xmlel{ns = ?NS_MUC_USER, name = 'x', children = [ #xmlel{ns = ?NS_MUC_USER, name = 'item', attrs = ItemAttrs1}, #xmlel{ns = ?NS_MUC_USER, name = 'status', - attrs = [?XMLATTR('code', + attrs = [?XMLATTR(<<"code">>, <<"303">>)]}]}]}, Packet2 = exmpp_xml:append_child( @@ -2216,9 +2216,9 @@ process_iq_admin(From, get, Lang, SubEl, StateData) -> Item -> FAffiliation = get_affiliation(From, StateData), FRole = get_role(From, StateData), - case exmpp_xml:get_attribute_as_binary(Item, 'role', false) of + case exmpp_xml:get_attribute_as_binary(Item, <<"role">>, false) of false -> - case exmpp_xml:get_attribute_as_binary(Item, 'affiliation', false) of + case exmpp_xml:get_attribute_as_binary(Item, <<"affiliation">>, false) of false -> {error, 'bad-request'}; StrAffiliation -> @@ -2267,9 +2267,9 @@ items_with_affiliation(SAffiliation, StateData) -> fun({JID, {Affiliation, Reason}}) -> {N, D, R} = JID, #xmlel{name = 'item', - attrs = [?XMLATTR('affiliation', + attrs = [?XMLATTR(<<"affiliation">>, affiliation_to_binary(Affiliation)), - ?XMLATTR('jid', + ?XMLATTR(<<"jid">>, exmpp_jid:to_binary(N, D, R))], children = [ #xmlel{name = 'reason', children = [#xmlcdata{cdata = Reason}]}]}; @@ -2277,9 +2277,9 @@ items_with_affiliation(SAffiliation, StateData) -> ({JID, Affiliation}) -> {N, D, R} = JID, #xmlel{name = 'item', - attrs = [?XMLATTR('affiliation', + attrs = [?XMLATTR(<<"affiliation">>, affiliation_to_binary(Affiliation)), - ?XMLATTR('jid', + ?XMLATTR(<<"jid">>, exmpp_jid:to_binary(N, D, R))]} end, search_affiliation(SAffiliation, StateData)). @@ -2290,10 +2290,10 @@ user_to_item(#user{role = Role, Affiliation = get_affiliation(JID, StateData), #xmlel{name = 'item', attrs = [ - ?XMLATTR('role', role_to_binary(Role)), - ?XMLATTR('affiliation', affiliation_to_binary(Affiliation)), - ?XMLATTR('nick', Nick), - ?XMLATTR('jid', exmpp_jid:to_binary(JID))] + ?XMLATTR(<<"role">>, role_to_binary(Role)), + ?XMLATTR(<<"affiliation">>, affiliation_to_binary(Affiliation)), + ?XMLATTR(<<"nick">>, Nick), + ?XMLATTR(<<"jid">>, exmpp_jid:to_binary(JID))] }. search_role(Role, StateData) -> @@ -2418,7 +2418,7 @@ find_changed_items(UJID, UAffiliation, URole, [#xmlcdata{} | Items], find_changed_items(UJID, UAffiliation, URole, [#xmlel{name = 'item'} = Item | Items], Lang, StateData, Res) -> - TJID = case exmpp_xml:get_attribute_as_binary(Item, 'jid',false) of + TJID = case exmpp_xml:get_attribute_as_binary(Item, <<"jid">>,false) of S when S =/= false -> try exmpp_jid:parse(S) of J -> @@ -2432,7 +2432,7 @@ find_changed_items(UJID, UAffiliation, URole, {error, ?ERR(Item, 'not-acceptable', Lang, ErrText)} end; _ -> - case exmpp_xml:get_attribute(Item, 'nick', false) of + case exmpp_xml:get_attribute(Item, <<"nick">>, false) of N when N =/= false -> case find_jid_by_nick(N, StateData) of false -> @@ -2454,9 +2454,9 @@ find_changed_items(UJID, UAffiliation, URole, {value, JID} -> TAffiliation = get_affiliation(JID, StateData), TRole = get_role(JID, StateData), - case exmpp_xml:get_attribute_as_binary(Item, 'role',false) of + case exmpp_xml:get_attribute_as_binary(Item, <<"role">>,false) of false -> - case exmpp_xml:get_attribute_as_binary(Item, 'affiliation', false) of + case exmpp_xml:get_attribute_as_binary(Item, <<"affiliation">>, false) of false -> {error, 'bad-request'}; StrAffiliation -> @@ -2764,8 +2764,8 @@ send_kickban_presence1(UJID, Reason, Code, Affiliation, StateData) -> SAffiliation = affiliation_to_binary(Affiliation), lists:foreach( fun({_LJID, Info}) -> - ItemAttrs = [?XMLATTR('affiliation', SAffiliation), - ?XMLATTR('role', <<"none">>)], + ItemAttrs = [?XMLATTR(<<"affiliation">>, SAffiliation), + ?XMLATTR(<<"role">>, <<"none">>)], ItemEls = case Reason of "" -> []; @@ -2776,14 +2776,14 @@ send_kickban_presence1(UJID, Reason, Code, Affiliation, StateData) -> Packet = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', - attrs = [?XMLATTR('type', <<"unavailable">>)], + attrs = [?XMLATTR(<<"type">>, <<"unavailable">>)], children = [#xmlel{ns = ?NS_MUC_USER, name = 'x', children = [ #xmlel{ns = ?NS_MUC_USER, name = 'item', attrs = ItemAttrs, children = ItemEls}, #xmlel{ns = ?NS_MUC_USER, name = 'status', - attrs = [?XMLATTR('code', + attrs = [?XMLATTR(<<"code">>, Code)]}]}]}, ejabberd_router:route( jid_replace_resource(StateData#state.jid, Nick), @@ -2802,7 +2802,7 @@ process_iq_owner(From, set, Lang, SubEl, StateData) -> owner -> case exmpp_xml:get_child_elements(SubEl) of [#xmlel{ns = XMLNS, name = 'x'} = XEl] -> - case {XMLNS, exmpp_xml:get_attribute_as_binary(XEl, 'type',false)} of + case {XMLNS, exmpp_xml:get_attribute_as_binary(XEl, <<"type">>,false)} of {?NS_DATA_FORMS, <<"cancel">>} -> {result, [], StateData}; {?NS_DATA_FORMS, <<"submit">>} -> @@ -2842,7 +2842,7 @@ process_iq_owner(From, get, Lang, SubEl, StateData) -> [] -> get_config(Lang, StateData, From); [Item] -> - case exmpp_xml:get_attribute_as_binary(Item, 'affiliation',false) of + case exmpp_xml:get_attribute_as_binary(Item, <<"affiliation">>,false) of false -> {error, 'bad-request'}; StrAffiliation -> @@ -2954,9 +2954,9 @@ is_password_settings_correct(XEl, StateData) -> -define(XFIELD(Type, Label, Var, Val), #xmlel{name = 'field', - attrs = [?XMLATTR('type', Type), - ?XMLATTR('label', translate:translate(Lang, Label)), - ?XMLATTR('var', Var)], + attrs = [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"label">>, translate:translate(Lang, Label)), + ?XMLATTR(<<"var">>, Var)], children = [#xmlel{name = 'value', children = [#xmlcdata{cdata = Val} ]}]}). @@ -2996,8 +2996,8 @@ get_config(Lang, StateData, From) -> list_to_binary(io_lib:format(translate:translate(Lang, "Configuration of room ~s"), [exmpp_jid:to_list(StateData#state.jid)])) }]}, - #xmlel{name = 'field', attrs = [?XMLATTR('type', <<"hidden">>), - ?XMLATTR('var', <<"FORM_TYPE">>)], + #xmlel{name = 'field', attrs = [?XMLATTR(<<"type">>, <<"hidden">>), + ?XMLATTR(<<"var">>, <<"FORM_TYPE">>)], children = [#xmlel{name = 'value', children = [#xmlcdata{cdata = <<"http://jabber.org/protocol/muc#roomconfig">> }]}]}, @@ -3032,44 +3032,44 @@ get_config(Lang, StateData, From) -> false -> "" end), #xmlel{name = 'field', attrs = [ - ?XMLATTR('type', <<"list-single">>), - ?XMLATTR('label', translate:translate(Lang, + ?XMLATTR(<<"type">>, <<"list-single">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, "Maximum Number of Occupants")), - ?XMLATTR('var', <<"muc#roomconfig_maxusers">>)], + ?XMLATTR(<<"var">>, <<"muc#roomconfig_maxusers">>)], children = [#xmlel{name = 'value', children = [#xmlcdata{cdata = list_to_binary(MaxUsersRoomString)}]}] ++ if is_integer(ServiceMaxUsers) -> []; true -> - [#xmlel{name = 'option', attrs = [?XMLATTR('label', + [#xmlel{name = 'option', attrs = [?XMLATTR(<<"label">>, translate:translate(Lang, "No limit"))], children = [#xmlel{name = 'value', children = [#xmlcdata{cdata = <<"none">>}]}]}] end ++ - [#xmlel{name = 'option', attrs = [?XMLATTR('label', N)], + [#xmlel{name = 'option', attrs = [?XMLATTR(<<"label">>, N)], children = [#xmlel{name = 'value', children = [ #xmlcdata{cdata = list_to_binary(erlang:integer_to_list(N))}]}]} || N <- lists:usort([ServiceMaxUsers, DefaultRoomMaxUsers, MaxUsersRoomInteger | ?MAX_USERS_DEFAULT_LIST]), N =< ServiceMaxUsers]}, #xmlel{name = 'field', attrs = [ - ?XMLATTR('type', <<"list-single">>), - ?XMLATTR('label', + ?XMLATTR(<<"type">>, <<"list-single">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, "Present real Jabber IDs to")), - ?XMLATTR('var', <<"muc#roomconfig_whois">>)], + ?XMLATTR(<<"var">>, <<"muc#roomconfig_whois">>)], children = [#xmlel{name = 'value', children = [#xmlcdata{cdata = if Config#config.anonymous -> <<"moderators">>; true -> <<"anyone">> end}]}, #xmlel{name = 'option', attrs = [ - ?XMLATTR('label', + ?XMLATTR(<<"label">>, translate:translate(Lang, "moderators only"))], children = [#xmlel{name = 'value', children = [#xmlcdata{cdata = <<"moderators">>}]}]}, #xmlel{name = 'option', attrs = [ - ?XMLATTR('label', + ?XMLATTR(<<"label">>, translate:translate(Lang, "anyone"))], children = [#xmlel{name = 'value', children = [#xmlcdata{cdata = @@ -3122,7 +3122,7 @@ get_config(Lang, StateData, From) -> #xmlcdata{cdata = translate:translate(Lang, "You need an x:data capable client to configure room")}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'x', - attrs = [?XMLATTR('type', <<"form">>)], + attrs = [?XMLATTR(<<"type">>, <<"form">>)], children = Res}], StateData}. @@ -3364,11 +3364,11 @@ destroy_room(DEl, StateData) -> lists:foreach( fun({_LJID, Info}) -> Nick = Info#user.nick, - ItemAttrs = [?XMLATTR('affiliation', <<"none">>), - ?XMLATTR('role', <<"none">>)], + ItemAttrs = [?XMLATTR(<<"affiliation">>, <<"none">>), + ?XMLATTR(<<"role">>, <<"none">>)], Packet = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'presence', - attrs = [?XMLATTR('type', + attrs = [?XMLATTR(<<"type">>, <<"unavailable">>)], children = [ #xmlel{ns = ?NS_MUC_USER, name = 'x', children = @@ -3394,7 +3394,7 @@ destroy_room(DEl, StateData) -> % Disco -define(FEATURE(Var), #xmlel{name = 'feature', - attrs = [?XMLATTR('var', Var)]}). + attrs = [?XMLATTR(<<"var">>, Var)]}). -define(CONFIG_OPT_TO_FEATURE(Opt, Fiftrue, Fiffalse), case Opt of @@ -3410,13 +3410,13 @@ process_iq_disco_info(_From, set, _Lang, _StateData) -> process_iq_disco_info(_From, get, Lang, StateData) -> Config = StateData#state.config, {result, [ #xmlel{name = 'identity', - attrs = [?XMLATTR('category', + attrs = [?XMLATTR(<<"category">>, <<"conference">>), - ?XMLATTR('type', <<"text">>), - ?XMLATTR('name', + ?XMLATTR(<<"type">>, <<"text">>), + ?XMLATTR(<<"name">>, get_title(StateData))]}, #xmlel{name = 'feature', - attrs = [?XMLATTR('var', ?NS_MUC_s)]}, + attrs = [?XMLATTR(<<"var">>, ?NS_MUC_s)]}, ?CONFIG_OPT_TO_FEATURE(Config#config.public, "muc_public", "muc_hidden"), @@ -3433,15 +3433,15 @@ process_iq_disco_info(_From, get, Lang, StateData) -> ] ++ iq_disco_info_extras(Lang, StateData), StateData}. -define(RFIELDT(Type, Var, Val), - #xmlel{name = 'field', attrs = [?XMLATTR('type', Type), - ?XMLATTR('var', Var)], + #xmlel{name = 'field', attrs = [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"var">>, Var)], children = [#xmlel{name = 'value', children = [#xmlcdata{cdata = list_to_binary(Val)}]}]}). -define(RFIELD(Label, Var, Val), - #xmlel{name = 'field', attrs = [?XMLATTR('label', + #xmlel{name = 'field', attrs = [?XMLATTR(<<"label">>, translate:translate(Lang, Label)), - ?XMLATTR('var', Var)], + ?XMLATTR(<<"var">>, Var)], children = [#xmlel{name = 'value', children = [ #xmlcdata{cdata = list_to_binary(Val)}]}]}). @@ -3449,7 +3449,7 @@ iq_disco_info_extras(Lang, StateData) -> Len = length(?DICT:to_list(StateData#state.users)), RoomDescription = (StateData#state.config)#config.description, [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', - attrs = [?XMLATTR('type', <<"result">>)], + attrs = [?XMLATTR(<<"type">>, <<"result">>)], children = [?RFIELDT("hidden", "FORM_TYPE", "http://jabber.org/protocol/muc#roominfo"), @@ -3520,12 +3520,12 @@ get_mucroom_disco_items(StateData) -> lists:map( fun({_LJID, Info}) -> Nick = Info#user.nick, - #xmlel{name = 'item', attrs = [?XMLATTR('jid', + #xmlel{name = 'item', attrs = [?XMLATTR(<<"jid">>, exmpp_jid:to_binary( StateData#state.room, StateData#state.host, Nick)), - ?XMLATTR('name', + ?XMLATTR(<<"name">>, Nick)]} end, ?DICT:to_list(StateData#state.users)). @@ -3554,7 +3554,7 @@ check_invitation(From, Els, Lang, StateData) -> throw({error, 'bad-request'}) end, JID = try exmpp_jid:parse(exmpp_xml:get_attribute_as_binary(InviteEl, - 'to', + <<"to">>, false)) of JID1 -> JID1 catch @@ -3579,7 +3579,7 @@ check_invitation(From, Els, Lang, StateData) -> IEl = [#xmlel{ns = ?NS_MUC_USER, name = 'invite', - attrs = [?XMLATTR('from', + attrs = [?XMLATTR(<<"from">>, exmpp_jid:to_binary(From))], children = [#xmlel{ns =?NS_MUC_USER, name = 'reason', children = [#xmlcdata{cdata = Reason} ]}] @@ -3621,11 +3621,11 @@ check_invitation(From, Els, Lang, StateData) -> %%TODO: always NS_JABBER_CLIENT? Msg = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', - attrs = [?XMLATTR('type', <<"normal">>)], + attrs = [?XMLATTR(<<"type">>, <<"normal">>)], children = [#xmlel{ns = ?NS_MUC_USER, name = 'x', children = IEl ++ PasswdEl}, #xmlel{ns = 'jabber:x:conference', name = 'x', - attrs = [?XMLATTR('jid', + attrs = [?XMLATTR(<<"jid">>, exmpp_jid:to_binary( StateData#state.room, StateData#state.host) @@ -3655,7 +3655,7 @@ check_decline_invitation(Packet) -> #xmlel{name = 'message'} = Packet, #xmlel{ns = ?NS_MUC_USER} = XEl = exmpp_xml:get_element(Packet, 'x'), DEl = exmpp_xml:get_element(XEl, 'decline'), - ToString = exmpp_xml:get_attribute_as_binary(DEl, 'to', false), + ToString = exmpp_xml:get_attribute_as_binary(DEl, <<"to">>, false), ToJID = exmpp_jid:parse(ToString), {true, {Packet, XEl, DEl, ToJID}}. @@ -3666,7 +3666,7 @@ send_decline_invitation({Packet, XEl, DEl = #xmlel{name='decline'}, ToJID}, FromString = exmpp_jid:to_binary(FromJID), DEl1 = exmpp_xml:remove_attribute(DEl, 'to'), - DEl2 = exmpp_xml:set_attribute(DEl1, 'from',FromString), + DEl2 = exmpp_xml:set_attribute(DEl1, <<"from">>,FromString), XEl2 = replace_subelement(XEl,DEl2), Packet2 = replace_subelement(Packet,XEl2), ejabberd_router:route(RoomJID, ToJID, Packet2). diff --git a/src/mod_multicast.erl b/src/mod_multicast.erl index 5d95b9ab9..58f954ca8 100644 --- a/src/mod_multicast.erl +++ b/src/mod_multicast.erl @@ -206,7 +206,7 @@ handle_info({route, From, To, #xmlel{name=iq} = Packet}, State) -> ejabberd_router:route(To, From, Err); reply -> LServiceS = jts(To), - case exmpp_xml:get_attribute_as_list(Packet, type, "error") of + case exmpp_xml:get_attribute_as_list(Packet, <<"type">>, "error") of "result" -> process_iqreply_result(From, LServiceS, Packet, State); "error" -> process_iqreply_error(From, LServiceS, Packet) end @@ -299,13 +299,13 @@ process_iq(_, #iq{type=Type}, _) when Type==result; Type==error -> process_iq(_, _IQ, _) -> unknown_iq. --define(FEATURE(Feat), #xmlel{name = feature, attrs = [#xmlattr{name = var, value = Feat}]}). +-define(FEATURE(Feat), #xmlel{name = feature, attrs = [#xmlattr{name = <<"var">>, value = Feat}]}). iq_disco_info(From, Lang, State) -> [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', - attrs = [?XMLATTR('category', <<"service">>), - ?XMLATTR('type', <<"multicast">>), - ?XMLATTR('name', translate:translate(Lang, + attrs = [?XMLATTR(<<"category">>, <<"service">>), + ?XMLATTR(<<"type">>, <<"multicast">>), + ?XMLATTR(<<"name">>, translate:translate(Lang, "Multicast"))]}, ?FEATURE(?NS_DISCO_INFO_b), ?FEATURE(?NS_DISCO_ITEMS_b), @@ -342,8 +342,8 @@ route_trusted(LServiceS, LServerS, FromJID, Destinations, Packet) -> DS = jts(D), XML = #xmlel{name = address, ns = ?NS_ADDRESS, - attrs = [#xmlattr{name = type, value = <<"bcc">>}, - #xmlattr{name = jid, value = list_to_binary(DS)}] }, + attrs = [#xmlattr{name = <<"type">>, value = <<"bcc">>}, + #xmlattr{name = <<"jid">>, value = list_to_binary(DS)}] }, #dest{jid_string = DS, jid_jid = D, type = "bcc", @@ -479,10 +479,10 @@ split_addresses_todeliver(Addresses) -> fun(XML) -> case XML of #xmlel{name = address} = Packet -> - case exmpp_xml:get_attribute_as_binary(Packet, "delivered", no_delivered) of + case exmpp_xml:get_attribute_as_binary(Packet, <<"delivered">>, no_delivered) of <<"true">> -> false; _ -> - Type = exmpp_xml:get_attribute_as_binary(Packet, "type", no_type), + Type = exmpp_xml:get_attribute_as_binary(Packet, <<"type">>, no_type), case Type of <<"to">> -> true; <<"cc">> -> true; @@ -516,11 +516,11 @@ check_limit_dests(SLimits, FromJID, Packet, Addresses) -> convert_dest_record(XMLs) -> lists:map( fun(XML) -> - case exmpp_xml:get_attribute_as_list(XML, jid, "") of + case exmpp_xml:get_attribute_as_list(XML, <<"jid">>, "") of [] -> #dest{jid_string = none, full_xml = XML}; JIDS -> - Type = exmpp_xml:get_attribute_as_list(XML, type, ""), + Type = exmpp_xml:get_attribute_as_list(XML, <<"type">>, ""), JIDJ = stj(JIDS), #dest{jid_string = JIDS, jid_jid = JIDJ, @@ -603,7 +603,7 @@ build_other_xml(Dests) -> Dests). add_delivered(Stanza) -> - exmpp_xml:set_attribute(Stanza, delivered, 'true'). + exmpp_xml:set_attribute(Stanza, <<"delivered">>, <<"true">>). %%%================================== %%%% Add preliminary packets @@ -782,7 +782,7 @@ process_discoinfo_result2(From, FromS, LServiceS, Els, Waiter) -> fun(XML) -> case XML of #xmlel{name = feature, attrs = Attrs} -> - ?NS_ADDRESS_b == exmpp_xml:get_attribute_from_list_as_binary(Attrs, var, ""); + ?NS_ADDRESS_b == exmpp_xml:get_attribute_from_list_as_binary(Attrs, <<"var">>, ""); _ -> false end end, @@ -850,8 +850,9 @@ get_limits_els(Els) -> fun(XML, R) -> case XML of #xmlel{name = x, attrs = Attrs, children = SubEls} -> - case (?NS_DATA_FORMS_b == exmpp_xml:get_attribute_from_list_as_binary(Attrs, xmlns, "")) and - (<<"result">> == exmpp_xml:get_attribute_from_list_as_binary(Attrs, type, "")) of + %%TODO: do ask for "xmlns" works here?. Seems it should ask for namespace? + case (?NS_DATA_FORMS_b == exmpp_xml:get_attribute_from_list_as_binary(Attrs, <<"xmlns">>, "")) and + (<<"result">> == exmpp_xml:get_attribute_from_list_as_binary(Attrs, <<"type">>, "")) of true -> get_limits_fields(SubEls) ++ R; false -> R end; @@ -867,8 +868,8 @@ get_limits_fields(Fields) -> fun(Field) -> case Field of #xmlel{name = field, attrs = Attrs} -> - (<<"FORM_TYPE">> == exmpp_xml:get_attribute_from_list_as_binary(Attrs, var, "")) - and (<<"hidden">> == exmpp_xml:get_attribute_from_list_as_binary(Attrs, type, "")); + (<<"FORM_TYPE">> == exmpp_xml:get_attribute_from_list_as_binary(Attrs, <<"var">>, "")) + and (<<"hidden">> == exmpp_xml:get_attribute_from_list_as_binary(Attrs, <<"type">>, "")); _ -> false end end, @@ -887,7 +888,7 @@ get_limits_values(Values) -> %% TODO: Only one subel is expected here, but there may be several #xmlel{children = SubElsV} = exmpp_xml:get_element(SubEls, value), Number = exmpp_xml:get_cdata_from_list_as_list(SubElsV), - Name = exmpp_xml:get_attribute_from_list_as_list(Attrs, var, ""), + Name = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"var">>, ""), [{list_to_atom(Name), list_to_integer(Number)} | R]; _ -> R end @@ -906,7 +907,7 @@ process_discoitems_result(From, LServiceS, Els) -> %% For each one, if it's "item", look for jid case XML of #xmlel{name = item, attrs = Attrs} -> - Res ++ [exmpp_xml:get_attribute_from_list_as_list(Attrs, jid, "")]; + Res ++ [exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"jid">>, "")]; _ -> Res end end, @@ -1197,13 +1198,13 @@ fragment_dests(Dests, Limit_number) -> %% Some parts of code are borrowed from mod_muc_room.erl -define(RFIELDT(Type, Var, Val), - #xmlel{name = 'field', attrs = [?XMLATTR('type', Type), - ?XMLATTR('var', Var)], + #xmlel{name = 'field', attrs = [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"var">>, Var)], children = [#xmlel{name = 'value', children = [#xmlcdata{cdata = Val}]}]}). -define(RFIELDV(Var, Val), - #xmlel{name = 'field', attrs = [?XMLATTR('var', Var)], + #xmlel{name = 'field', attrs = [?XMLATTR(<<"var">>, Var)], children = [#xmlel{name = 'value', children = [#xmlcdata{cdata = Val}]}]}). @@ -1214,7 +1215,7 @@ iq_disco_info_extras(From, State) -> [] -> []; List_limits_xmpp -> Children = [?RFIELDT("hidden", "FORM_TYPE", ?NS_ADDRESS)] ++ List_limits_xmpp, - [#xmlel{name = x, ns = ?NS_DATA_FORMS, attrs = [#xmlattr{name = type, value = <<"result">>}], children = Children}] + [#xmlel{name = x, ns = ?NS_DATA_FORMS, attrs = [#xmlattr{name = <<"type">>, value = <<"result">>}], children = Children}] end. sender_type(From) -> diff --git a/src/mod_offline.erl b/src/mod_offline.erl index 068f45c20..2b074a231 100644 --- a/src/mod_offline.erl +++ b/src/mod_offline.erl @@ -320,7 +320,7 @@ find_x_event_chatstates([_ | Els], {A, B, _}) -> find_x_expire(_, []) -> 0; find_x_expire(TimeStamp, [#xmlel{ns = ?NS_MESSAGE_EXPIRE} = El | _Els]) -> - Val = exmpp_xml:get_attribute_as_list(El, 'seconds', ""), + Val = exmpp_xml:get_attribute_as_list(El, <<"seconds">>, ""), case catch list_to_integer(Val) of {'EXIT', _} -> 0; @@ -541,7 +541,7 @@ find_x_timestamp([{xmlcdata, _} | Els]) -> find_x_timestamp(Els); find_x_timestamp([#xmlel{ns = ?NS_DELAY} = El | Els]) -> - Stamp = exmpp_xml:get_attribute_as_list(El, 'stamp', ""), + Stamp = exmpp_xml:get_attribute_as_list(El, <<"stamp">>, ""), case jlib:datetime_string_to_timestamp(Stamp) of undefined -> find_x_timestamp(Els); {MegaSecs, Secs, _MicroSecs} -> MegaSecs * 1000000 + Secs @@ -611,11 +611,11 @@ user_queue(User, Server, Query, Lang) -> exmpp_xml:indent_document(Packet1, <<" ">>), [?DEFAULT_NS], ?PREFIXED_NS), ?XE("tr", - [?XAE("td", [?XMLATTR('class', <<"valign">>)], [?INPUT("checkbox", "selected", ID)]), - ?XAC("td", [?XMLATTR('class', <<"valign">>)], Time), - ?XAC("td", [?XMLATTR('class', <<"valign">>)], SFrom), - ?XAC("td", [?XMLATTR('class', <<"valign">>)], STo), - ?XAE("td", [?XMLATTR('class', <<"valign">>)], [?XC("pre", FPacket)])] + [?XAE("td", [?XMLATTR(<<"class">>, <<"valign">>)], [?INPUT("checkbox", "selected", ID)]), + ?XAC("td", [?XMLATTR(<<"class">>, <<"valign">>)], Time), + ?XAC("td", [?XMLATTR(<<"class">>, <<"valign">>)], SFrom), + ?XAC("td", [?XMLATTR(<<"class">>, <<"valign">>)], STo), + ?XAE("td", [?XMLATTR(<<"class">>, <<"valign">>)], [?XC("pre", FPacket)])] ) end, Msgs), [?XC("h1", io_lib:format(?T("~s's Offline Messages Queue"), @@ -624,7 +624,7 @@ user_queue(User, Server, Query, Lang) -> ok -> [?CT("Submitted"), ?P]; nothing -> [] end ++ - [?XAE("form", [?XMLATTR('action', <<"">>), ?XMLATTR('method', <<"post">>)], + [?XAE("form", [?XMLATTR(<<"action">>, <<"">>), ?XMLATTR(<<"method">>, <<"post">>)], [?XE("table", [?XE("thead", [?XE("tr", @@ -638,7 +638,7 @@ user_queue(User, Server, Query, Lang) -> if FMsgs == [] -> [?XE("tr", - [?XAC("td", [?XMLATTR('colspan', <<"4">>)], " ")] + [?XAC("td", [?XMLATTR(<<"colspan">>, <<"4">>)], " ")] )]; true -> FMsgs diff --git a/src/mod_offline_odbc.erl b/src/mod_offline_odbc.erl index 0896d1044..8d42f2369 100644 --- a/src/mod_offline_odbc.erl +++ b/src/mod_offline_odbc.erl @@ -289,7 +289,7 @@ find_x_event_chatstates([_ | Els], {A, B, _}) -> find_x_expire(_, []) -> never; find_x_expire(TimeStamp, [#xmlel{ns = ?NS_MESSAGE_EXPIRE} = El | _Els]) -> - Val = exmpp_xml:get_attribute_as_list(El, 'seconds', ""), + Val = exmpp_xml:get_attribute_as_list(El, <<"seconds">>, ""), case catch list_to_integer(Val) of {'EXIT', _} -> never; @@ -319,7 +319,7 @@ pop_offline_messages(Ls, User, Server) try [El] = exmpp_xml:parse_document(XML, [names_as_atom, {check_elems, xmpp}, - {check_nss,xmpp}, {check_attrs,xmpp}]), + {check_nss,xmpp} ]), To = exmpp_jid:parse( exmpp_stanza:get_recipient(El)), From = exmpp_jid:parse( @@ -400,7 +400,7 @@ user_queue(User, Server, Query, Lang) -> fun({_, XML}) -> try exmpp_xml:parse_document(XML, [names_as_atom, {check_elems, xmpp}, - {check_nss,xmpp}, {check_attrs,xmpp}]) of + {check_nss,xmpp}]) of [El] -> [El] catch @@ -426,8 +426,8 @@ user_queue(User, Server, Query, Lang) -> exmpp_xml:indent_document(Packet, <<" ">>), [?DEFAULT_NS], ?PREFIXED_NS), ?XE("tr", - [?XAE("td", [?XMLATTR('class', <<"valign">>)], [?INPUT("checkbox", "selected", ID)]), - ?XAE("td", [?XMLATTR('class', <<"valign">>)], [?XC("pre", FPacket)])] + [?XAE("td", [?XMLATTR(<<"class">>, <<"valign">>)], [?INPUT("checkbox", "selected", ID)]), + ?XAE("td", [?XMLATTR(<<"class">>, <<"valign">>)], [?XC("pre", FPacket)])] ) end, Msgs), [?XC("h1", io_lib:format(?T("~s's Offline Messages Queue"), @@ -436,7 +436,7 @@ user_queue(User, Server, Query, Lang) -> ok -> [?XREST("Submitted")]; nothing -> [] end ++ - [?XAE("form", [?XMLATTR('action', <<"">>), ?XMLATTR('method', <<"post">>)], + [?XAE("form", [?XMLATTR(<<"action">>, <<"">>), ?XMLATTR(<<"method">>, <<"post">>)], [?XE("table", [?XE("thead", [?XE("tr", @@ -447,7 +447,7 @@ user_queue(User, Server, Query, Lang) -> if FMsgs == [] -> [?XE("tr", - [?XAC("td", [?XMLATTR('colspan', <<"4">>)], " ")] + [?XAC("td", [?XMLATTR(<<"colspan">>, <<"4">>)], " ")] )]; true -> FMsgs @@ -472,7 +472,7 @@ user_queue_parse_query(Username, LServer, Query) -> fun({XML, Seq}) -> try exmpp_xml:parse_document(XML, [names_as_atom, {check_elems, xmpp}, - {check_nss,xmpp}, {check_attrs,xmpp}]) of + {check_nss,xmpp} ]) of [El] -> [{El, Seq}] catch diff --git a/src/mod_privacy.erl b/src/mod_privacy.erl index 26335d756..490710864 100644 --- a/src/mod_privacy.erl +++ b/src/mod_privacy.erl @@ -204,7 +204,7 @@ process_iq_get(_, From, _To, #iq{payload = SubEl}, [#xmlel{name = Name} = Child] -> case Name of list -> - ListName = exmpp_xml:get_attribute_as_list(Child, name, false), + ListName = exmpp_xml:get_attribute_as_list(Child, <<"name">>, false), process_list_get(LUser, LServer, ListName); _ -> {error, 'bad-request'} @@ -236,20 +236,20 @@ process_lists_get(LUser, LServer, Active) -> [] -> {result, #xmlel{ns = ?NS_PRIVACY, name = 'query'}}; _ -> - LItems = [exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = list}, name, N) || N <- Lists], + LItems = [exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = list}, <<"name">>, N) || N <- Lists], DItems = case Default of none -> LItems; _ -> - [exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = default}, name, Default) | LItems] + [exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = default}, <<"name">>, Default) | LItems] end, ADItems = case Active of none -> DItems; _ -> - [exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = active}, name, Active) | DItems] + [exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = active}, <<"name">>, Active) | DItems] end, {result, #xmlel{ns = ?NS_PRIVACY, name = 'query', children = ADItems}} end @@ -279,20 +279,20 @@ process_list_get(LUser, LServer, Name) -> {error, 'item-not-found'}; {atomic, List} -> LItems = lists:map(fun item_to_xml/1, List), - ListEl = exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = list, children = LItems}, name, Name), + ListEl = exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = list, children = LItems}, <<"name">>, Name), {result,#xmlel{ns = ?NS_PRIVACY, name = 'query', children = [ListEl]}} end. item_to_xml(Item) -> - Attrs1 = [?XMLATTR('action', action_to_binary(Item#privacy_list_data.action)), - ?XMLATTR('order', order_to_binary(Item#privacy_list_data.order))], + Attrs1 = [?XMLATTR(<<"action">>, action_to_binary(Item#privacy_list_data.action)), + ?XMLATTR(<<"order">>, order_to_binary(Item#privacy_list_data.order))], Attrs2 = case Item#privacy_list_data.type of none -> Attrs1; Type -> - [?XMLATTR('type', type_to_binary(Type)), - ?XMLATTR('value', Item#privacy_list_data.value) | + [?XMLATTR(<<"type">>, type_to_binary(Type)), + ?XMLATTR(<<"value">>, Item#privacy_list_data.value) | Attrs1] end, SubEls = case Item#privacy_list_data.match_all of @@ -359,7 +359,7 @@ process_iq_set(_, From, _To, #iq{payload = SubEl}) -> LServer = exmpp_jid:prep_domain_as_list(From), case exmpp_xml:get_child_elements(SubEl) of [#xmlel{name = Name} = Child] -> - ListName = exmpp_xml:get_attribute_as_list(Child, 'name', false), + ListName = exmpp_xml:get_attribute_as_list(Child, <<"name">>, false), case Name of list -> process_list_set(LUser, LServer, ListName, @@ -477,7 +477,7 @@ process_list_set(LUser, LServer, Name, Els) -> exmpp_jid:make(LUser, LServer), exmpp_jid:make(LUser, LServer), #xmlel{name = 'broadcast', ns = privacy_list, - attrs = [exmpp_xml:attribute(list_name, Name)], + attrs = [?XMLATTR(<<"list_name">>, Name)], children = [exmpp_xml:cdata(ListString)]}), Res; _ -> @@ -512,7 +512,7 @@ process_list_set(LUser, LServer, Name, Els) -> exmpp_jid:make(LUser, LServer), exmpp_jid:make(LUser, LServer), #xmlel{name = 'broadcast', ns = privacy_list, - attrs = [exmpp_xml:attribute(list_name, Name)], + attrs = [?XMLATTR(<<"list_name">>, Name)], children = [exmpp_xml:cdata(ListString)]}), Res; _ -> @@ -532,10 +532,10 @@ parse_items([], Res) -> %% lists:keysort(#listitem.order, Res); lists:reverse(Res); parse_items([El = #xmlel{name = item} | Els], Res) -> - Type = exmpp_xml:get_attribute_as_list(El, type, false), - Value = exmpp_xml:get_attribute_as_binary(El, value, false), - SAction =exmpp_xml:get_attribute_as_list(El, action, false), - SOrder = exmpp_xml:get_attribute_as_list(El, order, false), + Type = exmpp_xml:get_attribute_as_list(El, <<"type">>, false), + Value = exmpp_xml:get_attribute_as_binary(El, <<"value">>, false), + SAction =exmpp_xml:get_attribute_as_list(El, <<"action">>, false), + SOrder = exmpp_xml:get_attribute_as_list(El, <<"order">>, false), Action = case catch list_to_action(SAction) of {'EXIT', _} -> false; Val -> Val @@ -698,7 +698,7 @@ check_packet(_, User, Server, 'message' -> message; 'iq' -> iq; 'presence' -> - case exmpp_xml:get_attribute(El, type, '') of + case exmpp_xml:get_attribute(El, <<"type">>, '') of %% notification '' -> presence; 'unavailable' -> presence; diff --git a/src/mod_privacy_odbc.erl b/src/mod_privacy_odbc.erl index 025b2d79b..10a04aac7 100644 --- a/src/mod_privacy_odbc.erl +++ b/src/mod_privacy_odbc.erl @@ -91,7 +91,7 @@ process_iq_get(_, From, _To, #iq{payload = SubEl}, [#xmlel{name = Name} = Child] -> case Name of list -> - ListName = exmpp_xml:get_attribute_as_list(Child, name, false), + ListName = exmpp_xml:get_attribute_as_list(Child, <<"name">>, false), process_list_get(LUser, LServer, ListName); _ -> {error, 'bad-request'} @@ -116,21 +116,21 @@ process_lists_get(LUser, LServer, Active) -> {selected, ["name"], Names} -> LItems = lists:map( fun({N}) -> - exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = list}, name, N) + exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = list}, <<"name">>, N) end, Names), DItems = case Default of none -> LItems; _ -> - [exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = default}, name, Default) | LItems] + [exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = default}, <<"name">>, Default) | LItems] end, ADItems = case Active of none -> DItems; _ -> - [exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = active}, name, Active) | DItems] + [exmpp_xml:set_attribute(#xmlel{ns = ?NS_PRIVACY, name = active}, <<"name">>, Active) | DItems] end, {result, #xmlel{ns = ?NS_PRIVACY, name = 'query', children = ADItems}}; _ -> @@ -155,7 +155,7 @@ process_list_get(LUser, LServer, Name) -> ListEl = exmpp_xml:set_attribute(#xmlel{name = list, ns = ?NS_PRIVACY, children = LItems}, - name, + <<"name">>, Name), {result, #xmlel{ns = ?NS_PRIVACY, name = 'query', children = [ListEl]}}; _ -> @@ -167,14 +167,14 @@ process_list_get(LUser, LServer, Name) -> item_to_xml(Item) -> - Attrs1 = [?XMLATTR('action', action_to_binary(Item#listitem.action)), - ?XMLATTR('order', order_to_binary(Item#listitem.order))], + Attrs1 = [?XMLATTR(<<"action">>, action_to_binary(Item#listitem.action)), + ?XMLATTR(<<"order">>, order_to_binary(Item#listitem.order))], Attrs2 = case Item#listitem.type of none -> Attrs1; Type -> - [?XMLATTR('type', type_to_binary(Item#listitem.type)), - ?XMLATTR('value', value_to_binary(Type, Item#listitem.value)) | + [?XMLATTR(<<"type">>, type_to_binary(Item#listitem.type)), + ?XMLATTR(<<"value">>, value_to_binary(Type, Item#listitem.value)) | Attrs1] end, SubEls = case Item#listitem.match_all of @@ -256,7 +256,7 @@ process_iq_set(_, From, _To, #iq{payload = SubEl}) -> LServer = exmpp_jid:prep_domain_as_list(From), case exmpp_xml:get_child_elements(SubEl) of [#xmlel{name = Name} = Child] -> - ListName = exmpp_xml:get_attribute_as_list(Child, 'name', false), + ListName = exmpp_xml:get_attribute_as_list(Child, <<"name">>, false), case Name of list -> process_list_set(LUser, LServer, ListName, @@ -370,7 +370,7 @@ process_list_set(LUser, LServer, Name, Els) -> exmpp_jid:make(LUser, LServer), exmpp_jid:make(LUser, LServer), #xmlel{name = 'broadcast', ns = privacy_list, - attrs = [exmpp_xml:attribute(list_name, Name)], + attrs = [?XMLATTR(<<"list_name">>, Name)], children = [exmpp_xml:cdata(ListString)]}), Res; _ -> @@ -407,7 +407,7 @@ process_list_set(LUser, LServer, Name, Els) -> exmpp_jid:make(LUser, LServer), exmpp_jid:make(LUser, LServer), #xmlel{name = 'broadcast', ns = privacy_list, - attrs = [exmpp_xml:attribute(list_name, Name)], + attrs = [?XMLATTR(<<"list_name">>, Name)], children = [exmpp_xml:cdata(ListString)]}), Res; _ -> @@ -426,10 +426,10 @@ parse_items([], Res) -> %% Sort the items by their 'order' attribute lists:keysort(#listitem.order, Res); parse_items([El = #xmlel{name = item} | Els], Res) -> - Type = exmpp_xml:get_attribute_as_list(El, type, false), - Value = exmpp_xml:get_attribute_as_list(El, value, false), - SAction =exmpp_xml:get_attribute_as_list(El, action, false), - SOrder = exmpp_xml:get_attribute_as_list(El, order, false), + Type = exmpp_xml:get_attribute_as_list(El, <<"type">>, false), + Value = exmpp_xml:get_attribute_as_list(El, <<"value">>, false), + SAction =exmpp_xml:get_attribute_as_list(El, <<"action">>, false), + SOrder = exmpp_xml:get_attribute_as_list(El, <<"order">>, false), Action = case catch list_to_action(SAction) of {'EXIT', _} -> false; Val -> Val diff --git a/src/mod_private_odbc.erl b/src/mod_private_odbc.erl index 1b188799b..15e505bbf 100644 --- a/src/mod_private_odbc.erl +++ b/src/mod_private_odbc.erl @@ -158,7 +158,7 @@ get_data(LUser, LServer, [El | Els], Res) -> {selected, ["data"], [{SData}]} -> [Data] = exmpp_xml:parse_document(SData, [names_as_atom, {check_elems, xmpp}, - {check_nss,xmpp}, {check_attrs,xmpp}]), + {check_nss,xmpp} ]), get_data(LUser, LServer, Els, [Data | Res]); %% MREMOND: I wonder when the query could return a vcard ? {selected, ["vcard"], []} -> diff --git a/src/mod_proxy65/mod_proxy65_service.erl b/src/mod_proxy65/mod_proxy65_service.erl index 4ef785d07..ca15510fe 100644 --- a/src/mod_proxy65/mod_proxy65_service.erl +++ b/src/mod_proxy65/mod_proxy65_service.erl @@ -163,7 +163,7 @@ process_iq(InitiatorJID, #iq{type = set, payload = SubEl, ns = ?NS_BYTESTREAMS} case acl:match_rule(ServerHost, ACL, InitiatorJID) of allow -> ActivateEl = exmpp_xml:get_path(SubEl, [{element, 'activate'}]), - SID = exmpp_xml:get_attribute_as_list(SubEl, 'sid', ""), + SID = exmpp_xml:get_attribute_as_list(SubEl, <<"sid">>, ""), case catch exmpp_jid:parse(exmpp_xml:get_cdata_as_list(ActivateEl)) of TargetJID when ?IS_JID(TargetJID), SID /= "", length(SID) =< 128, TargetJID /= InitiatorJID -> @@ -201,13 +201,13 @@ process_iq(_, _, _) -> %%% Auxiliary functions. %%%------------------------- -define(FEATURE(Feat), #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', - attrs = [?XMLATTR('var', Feat)]}). + attrs = [?XMLATTR(<<"var">>, Feat)]}). iq_disco_info(Lang, Name) -> [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = - [?XMLATTR('category', <<"proxy">>), - ?XMLATTR('type', <<"bytestreams">>), - ?XMLATTR('name', translate:translate(Lang, Name))]}, + [?XMLATTR(<<"category">>, <<"proxy">>), + ?XMLATTR(<<"type">>, <<"bytestreams">>), + ?XMLATTR(<<"name">>, translate:translate(Lang, Name))]}, ?FEATURE(?NS_DISCO_INFO_s), ?FEATURE(?NS_VCARD_s), ?FEATURE(?NS_BYTESTREAMS_s)]. @@ -238,8 +238,8 @@ parse_options(ServerHost, Opts) -> HostNameStr -> HostNameStr end, - StreamAddr = [?XMLATTR('jid', MyHost), ?XMLATTR('host', HostName), - ?XMLATTR('port', Port)], + StreamAddr = [?XMLATTR(<<"jid">>, MyHost), ?XMLATTR(<<"host">>, HostName), + ?XMLATTR(<<"port">>, Port)], #state{myhost = MyHost, serverhost = ServerHost, name = Name, diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl index 2a0f03870..ef556ff72 100644 --- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -692,7 +692,7 @@ disco_local_identity(Acc, _From, #jid{domain = Host} = _To, <<>> = _NodeId, _Lan case lists:member(?PEPNODE, plugins(Host)) of true -> [#xmlel{name = 'identity', ns = ?NS_DISCO_INFO, - attrs = [?XMLATTR('category', <<"pubsub">>), ?XMLATTR('type', <<"pep">>)]} + attrs = [?XMLATTR(<<"category">>, <<"pubsub">>), ?XMLATTR(<<"type">>, <<"pep">>)]} | Acc]; false -> Acc end; @@ -762,19 +762,19 @@ disco_sm_identity(Acc, From, To, NodeId, _Lang) -> disco_identity(_Host, <<>> = _NodeId, _From) -> [#xmlel{name = 'identity', ns = ?NS_DISCO_INFO, - attrs = [?XMLATTR('category', <<"pubsub">>), ?XMLATTR('type', <<"pep">>)]}]; + attrs = [?XMLATTR(<<"category">>, <<"pubsub">>), ?XMLATTR(<<"type">>, <<"pep">>)]}]; disco_identity(#jid{node = U, domain = S, resource = R} = Host, NodeId, From) -> Action = fun(#pubsub_node{idx = NodeIdx, type = Type, options = Options, owners = Owners}) -> case get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) of {result, _} -> {result, [#xmlel{name = 'identity', ns = ?NS_DISCO_INFO, - attrs = [?XMLATTR('category', <<"pubsub">>), ?XMLATTR('type', <<"pep">>)]}, + attrs = [?XMLATTR(<<"category">>, <<"pubsub">>), ?XMLATTR(<<"type">>, <<"pep">>)]}, #xmlel{name = 'identity', ns = ?NS_DISCO_INFO, - attrs = [?XMLATTR('category', <<"pubsub">>), ?XMLATTR('type', <<"leaf">>) + attrs = [?XMLATTR(<<"category">>, <<"pubsub">>), ?XMLATTR(<<"type">>, <<"leaf">>) | case get_option(Options, 'title') of false -> []; - Title -> [?XMLATTR('name', Title)] + Title -> [?XMLATTR(<<"name">>, Title)] end ]}]}; {error, _} -> {result, []} @@ -858,11 +858,11 @@ disco_items(#jid{raw = JID, node = U, domain = S, resource = R} = Host, <<>>, Fr case get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) of {result, _} -> [#xmlel{name = 'item', ns = ?NS_DISCO_INFO, - attrs = [?XMLATTR('jid', JID), - ?XMLATTR('node', NodeId) | + attrs = [?XMLATTR(<<"jid">>, JID), + ?XMLATTR(<<"node">>, NodeId) | case get_option(Options, 'title') of false -> []; - [Title] -> [?XMLATTR('title', Title)] + [Title] -> [?XMLATTR(<<"title">>, Title)] end]} | Acc]; _ -> Acc @@ -879,8 +879,8 @@ disco_items(#jid{raw = JID, node = U, domain = S, resource = R} = Host, NodeId, {result, Items} -> {result, [#xmlel{name = 'item', ns = ?NS_DISCO_INFO, - attrs = [?XMLATTR('jid', JID), - ?XMLATTR('name', ItemId)]} + attrs = [?XMLATTR(<<"jid">>, JID), + ?XMLATTR(<<"name">>, ItemId)]} || #pubsub_item{id = {ItemId,_}} <- Items]}; _ -> {result, []} end @@ -1164,7 +1164,7 @@ do_route(ServerHost, Access, Plugins, Host, From, To, #xmlel{name = 'iq'} = Pack case exmpp_iq:xmlel_to_iq(Packet) of %% Service discovery : disco#info #iq{type = 'get', ns = ?NS_DISCO_INFO, payload = #xmlel{attrs = Attrs}, lang = Lang} -> - NodeId = exmpp_xml:get_attribute_from_list(Attrs, 'node', <<>>), + NodeId = exmpp_xml:get_attribute_from_list(Attrs, <<"node">>, <<>>), Info = ejabberd_hooks:run_fold( disco_info, ServerHost, [], [ServerHost, ?MODULE, <<>>, ""]), @@ -1181,7 +1181,7 @@ do_route(ServerHost, Access, Plugins, Host, From, To, #xmlel{name = 'iq'} = Pack ejabberd_router:route(To, From, Res); %% Service discovery : disco#items #iq{type = 'get', ns = ?NS_DISCO_ITEMS, payload = #xmlel{attrs = Attrs}} -> - NodeId = exmpp_xml:get_attribute_from_list(Attrs, 'node', <<>>), + NodeId = exmpp_xml:get_attribute_from_list(Attrs, <<"node">>, <<>>), Res = case iq_disco_items(Host, NodeId, From) of {result, IQRes} -> Result = #xmlel{ns = ?NS_DISCO_ITEMS, @@ -1258,8 +1258,8 @@ do_route(ServerHost, _Access, _Plugins, Host, From, To, undefined -> ok; #xmlel{attrs = Attrs, children = Els} = _Item -> - NodeId = exmpp_xml:get_attribute(Publish, 'node', <<>>), - ItemId = exmpp_xml:get_attribute_from_list(Attrs, 'id', <<>>), + NodeId = exmpp_xml:get_attribute(Publish, <<"node">>, <<>>), + ItemId = exmpp_xml:get_attribute_from_list(Attrs, <<"id">>, <<>>), case publish_item(Host, ServerHost, NodeId, From, ItemId, Els) of {result, _} -> ok; @@ -1302,19 +1302,19 @@ command_disco_info(_Host, ?NS_ADHOC_b = _NodeId, _From) -> {result, [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', - attrs = [?XMLATTR('category', <<"automation">>), - ?XMLATTR('type', <<"command-list">>)]}]}; + attrs = [?XMLATTR(<<"category">>, <<"automation">>), + ?XMLATTR(<<"type">>, <<"command-list">>)]}]}; command_disco_info(_Host, ?NS_PUBSUB_GET_PENDING_b = _NodeId, _From) -> {result, % Identity [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', - attrs = [?XMLATTR('category', <<"automation">>), - ?XMLATTR('type', <<"command-node">>)]}, + attrs = [?XMLATTR(<<"category">>, <<"automation">>), + ?XMLATTR(<<"type">>, <<"command-node">>)]}, % Features #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', - attrs = [?XMLATTR('var', ?NS_ADHOC)]}]}. + attrs = [?XMLATTR(<<"var">>, ?NS_ADHOC)]}]}. -spec(node_disco_info/3 :: @@ -1343,16 +1343,16 @@ node_disco_info(Host, NodeId, From) -> %% Identities [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', - attrs = [?XMLATTR('category', <<"pubsub">>), - ?XMLATTR('type', Type)]} || Type <- Types ] + attrs = [?XMLATTR(<<"category">>, <<"pubsub">>), + ?XMLATTR(<<"type">>, Type)]} || Type <- Types ] ++ %% Features [#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', - attrs = [?XMLATTR('var', ?NS_PUBSUB_b)]} | + attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_b)]} | [#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', - attrs = [?XMLATTR('var', list_to_binary(?NS_PUBSUB_s++"#"++Type))]} + attrs = [?XMLATTR(<<"var">>, list_to_binary(?NS_PUBSUB_s++"#"++Type))]} || Type <- features(Plugin)]]} end, case transaction(Host, NodeId, Action, sync_dirty) of @@ -1377,29 +1377,29 @@ iq_disco_info(Host, <<>> = _NodeId, _From, Lang) -> %% Identities [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', - attrs = [?XMLATTR('category', "pubsub"), - ?XMLATTR('type', "service"), - ?XMLATTR('name', translate:translate(Lang, "Publish-Subscribe"))]}, + attrs = [?XMLATTR(<<"category">>, "pubsub"), + ?XMLATTR(<<"type">>, "service"), + ?XMLATTR(<<"name">>, translate:translate(Lang, "Publish-Subscribe"))]}, %% Features #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', - attrs = [?XMLATTR('var', ?NS_DISCO_INFO_b)]}, + attrs = [?XMLATTR(<<"var">>, ?NS_DISCO_INFO_b)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', - attrs = [?XMLATTR('var', ?NS_DISCO_ITEMS_b)]}, + attrs = [?XMLATTR(<<"var">>, ?NS_DISCO_ITEMS_b)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', - attrs = [?XMLATTR('var', ?NS_PUBSUB_b)]}, + attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_b)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', - attrs = [?XMLATTR('var', ?NS_ADHOC_b)]}, + attrs = [?XMLATTR(<<"var">>, ?NS_ADHOC_b)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', - attrs = [?XMLATTR('var', ?NS_VCARD_b)]}] + attrs = [?XMLATTR(<<"var">>, ?NS_VCARD_b)]}] ++ [#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', - attrs = [?XMLATTR('var', list_to_binary(?NS_PUBSUB_s++"#"++Feature))]} + attrs = [?XMLATTR(<<"var">>, list_to_binary(?NS_PUBSUB_s++"#"++Feature))]} || Feature <- features(Host, <<>>)]}; iq_disco_info(Host, NodeId, From, _Lang) when NodeId == ?NS_ADHOC_b orelse NodeId == ?NS_PUBSUB_GET_PENDING_b -> @@ -1425,9 +1425,9 @@ iq_disco_items(Host, <<>> = _NodeId, From) -> Attrs = case get_option(Options, 'title') of false -> - [?XMLATTR('jid', Host) | nodeAttr(SubNodeId)]; + [?XMLATTR(<<"jid">>, Host) | nodeAttr(SubNodeId)]; Title -> - [?XMLATTR('jid', Host), ?XMLATTR('name', Title) | nodeAttr(SubNodeId)] + [?XMLATTR(<<"jid">>, Host), ?XMLATTR(<<"name">>, Title) | nodeAttr(SubNodeId)] end, #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = Attrs} end, Nodes)}; @@ -1439,9 +1439,9 @@ iq_disco_items(Host, ?NS_ADHOC_b = _NodeId, _From) -> {result, [#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', - attrs = [?XMLATTR('jid', Host), - ?XMLATTR('node', ?NS_PUBSUB_GET_PENDING_b), - ?XMLATTR('name', "Get Pending")]}]}; + attrs = [?XMLATTR(<<"jid">>, Host), + ?XMLATTR(<<"node">>, ?NS_PUBSUB_GET_PENDING_b), + ?XMLATTR(<<"name">>, "Get Pending")]}]}; iq_disco_items(_Host, ?NS_PUBSUB_GET_PENDING_b = _NodeId, _From) -> %% TODO {result, []}; @@ -1456,9 +1456,9 @@ iq_disco_items(Host, NodeId, From) -> Attrs = case get_option(SubOptions, 'title') of false -> - [?XMLATTR('jid', Host) | nodeAttr(SubNodeId)]; + [?XMLATTR(<<"jid">>, Host) | nodeAttr(SubNodeId)]; Title -> - [?XMLATTR('jid', Host), ?XMLATTR('name', Title) | nodeAttr(SubNodeId)] + [?XMLATTR(<<"jid">>, Host), ?XMLATTR(<<"name">>, Title) | nodeAttr(SubNodeId)] end, #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', @@ -1469,8 +1469,8 @@ iq_disco_items(Host, NodeId, From) -> {result, Name} = node_call(Type, get_item_name, [Host, NodeId, RN]), #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', - attrs = [?XMLATTR('jid', Host), - ?XMLATTR('name', Name)]} + attrs = [?XMLATTR(<<"jid">>, Host), + ?XMLATTR(<<"name">>, Name)]} end, NodeItems), {result, Nodes ++ Items} end, @@ -1573,7 +1573,7 @@ iq_pubsub(Host, ServerHost, From, IQType, #xmlel{children = Els}, Lang, Access, case exmpp_xml:remove_cdata_from_list(Els) of [#xmlel{name = Name, attrs = Attrs, children = SubEls} | Rest] -> %% Fix bug when owner retrieves his affiliations - NodeId = exmpp_xml:get_attribute_from_list(Attrs, 'node', <<>>), + NodeId = exmpp_xml:get_attribute_from_list(Attrs, <<"node">>, <<>>), case {IQType, Name} of {'set', 'create'} -> Config = case Rest of @@ -1581,7 +1581,7 @@ iq_pubsub(Host, ServerHost, From, IQType, #xmlel{children = Els}, Lang, Access, _ -> [] end, %% Get the type of the node - Plugin = case exmpp_xml:get_attribute_from_list_as_list(Attrs, 'type', "") of + Plugin = case exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"type">>, "") of "" -> hd(Plugins); T -> T end, @@ -1596,7 +1596,7 @@ iq_pubsub(Host, ServerHost, From, IQType, #xmlel{children = Els}, Lang, Access, {'set', 'publish'} -> case exmpp_xml:remove_cdata_from_list(SubEls) of [#xmlel{name = 'item', attrs = ItemAttrs, children = Payload}] -> - ItemId = exmpp_xml:get_attribute_from_list(ItemAttrs, 'id', <<>>), + ItemId = exmpp_xml:get_attribute_from_list(ItemAttrs, <<"id">>, <<>>), publish_item(Host, ServerHost, NodeId, From, ItemId, exmpp_xml:remove_cdata_from_list(Payload)); [] -> @@ -1607,14 +1607,14 @@ iq_pubsub(Host, ServerHost, From, IQType, #xmlel{children = Els}, Lang, Access, {error, extended_error('bad-request', "invalid-payload")} end; {'set', 'retract'} -> - ForceNotify = case exmpp_xml:get_attribute_from_list(Attrs, 'notify', <<>>) of + ForceNotify = case exmpp_xml:get_attribute_from_list(Attrs, <<"notify">>, <<>>) of <<"1">> -> true; <<"true">> -> true; _ -> false end, case exmpp_xml:remove_cdata_from_list(SubEls) of [#xmlel{name = 'item', attrs = ItemAttrs}] -> - ItemId = exmpp_xml:get_attribute_from_list(ItemAttrs, 'id', <<>>), + ItemId = exmpp_xml:get_attribute_from_list(ItemAttrs, <<"id">>, <<>>), delete_item(Host, NodeId, From, ItemId, ForceNotify); _ -> %% Request does not specify an item @@ -1625,18 +1625,18 @@ iq_pubsub(Host, ServerHost, From, IQType, #xmlel{children = Els}, Lang, Access, [#xmlel{name = 'options', children = C}] -> C; _ -> [] end, - JID = exmpp_xml:get_attribute_from_list(Attrs, 'jid', <<>>), + JID = exmpp_xml:get_attribute_from_list(Attrs, <<"jid">>, <<>>), subscribe_node(Host, NodeId, From, JID, Config); {'set', 'unsubscribe'} -> - JID = exmpp_xml:get_attribute_from_list(Attrs, 'jid', <<>>), - SubId = exmpp_xml:get_attribute_from_list(Attrs, 'subid', <<>>), + JID = exmpp_xml:get_attribute_from_list(Attrs, <<"jid">>, <<>>), + SubId = exmpp_xml:get_attribute_from_list(Attrs, <<"subid">>, <<>>), unsubscribe_node(Host, NodeId, From, JID, SubId); {'get', 'items'} -> - MaxItems = exmpp_xml:get_attribute_from_list(Attrs, 'max_items', <<>>), - SubId = exmpp_xml:get_attribute_from_list(Attrs, 'subid', <<>>), + MaxItems = exmpp_xml:get_attribute_from_list(Attrs, <<"max_items">>, <<>>), + SubId = exmpp_xml:get_attribute_from_list(Attrs, <<"subid">>, <<>>), ItemIds = lists:foldl(fun (#xmlel{name = 'item', attrs = ItemAttrs}, Acc) -> - case exmpp_xml:get_attribute_from_list(ItemAttrs, 'id', <<>>) of + case exmpp_xml:get_attribute_from_list(ItemAttrs, <<"id">>, <<>>) of <<>> -> Acc; ItemId -> [ItemId|Acc] end; @@ -1648,12 +1648,12 @@ iq_pubsub(Host, ServerHost, From, IQType, #xmlel{children = Els}, Lang, Access, {'get', 'affiliations'} -> get_affiliations(Host, From, Plugins); {'get', 'options'} -> - SubId = exmpp_xml:get_attribute_from_list(Attrs, 'subid', <<>>), - JID = exmpp_xml:get_attribute_from_list(Attrs, 'jid', <<>>), + SubId = exmpp_xml:get_attribute_from_list(Attrs, <<"subid">>, <<>>), + JID = exmpp_xml:get_attribute_from_list(Attrs, <<"jid">>, <<>>), get_options(Host, NodeId, JID, SubId, Lang); {'set', 'options'} -> - SubId = exmpp_xml:get_attribute_from_list(Attrs, 'subid', <<>>), - JID = exmpp_xml:get_attribute_from_list(Attrs, 'jid', <<>>), + SubId = exmpp_xml:get_attribute_from_list(Attrs, <<"subid">>, <<>>), + JID = exmpp_xml:get_attribute_from_list(Attrs, <<"jid">>, <<>>), set_options(Host, NodeId, JID, SubId, SubEls); _ -> {error, 'feature-not-implemented'} @@ -1678,7 +1678,7 @@ iq_pubsub(Host, ServerHost, From, IQType, #xmlel{children = Els}, Lang, Access, iq_pubsub_owner(Host, ServerHost, From, IQType, #xmlel{children = Els}, Lang) -> case Action = exmpp_xml:remove_cdata_from_list(Els) of [#xmlel{name = Name, attrs = Attrs, children = SubEls}] -> - NodeId = exmpp_xml:get_attribute_from_list(Attrs, 'node', <<>>), + NodeId = exmpp_xml:get_attribute_from_list(Attrs, <<"node">>, <<>>), case {IQType, Name} of {'get', 'configure'} -> get_configure(Host, ServerHost, NodeId, From, Lang); @@ -1814,11 +1814,11 @@ send_pending_node_form(Host, Owner, _Lang, Plugins) -> children = [ exmpp_xml:cdata(node_to_string(Node))]}]} end, get_pending_nodes(Host, Owner, Ps)), - XForm = #xmlel{ns = ?NS_DATA_FORMS, name ='x', attrs = [?XMLATTR('type', <<"form">>)], + XForm = #xmlel{ns = ?NS_DATA_FORMS, name ='x', attrs = [?XMLATTR(<<"type">>, <<"form">>)], children = [ #xmlel{ns = ?NS_DATA_FORMS, name = 'field', - attrs = [?XMLATTR('type', <<"list-single">>), - ?XMLATTR('var', <<"pubsub#node">>)], + attrs = [?XMLATTR(<<"type">>, <<"list-single">>), + ?XMLATTR(<<"var">>, <<"pubsub#node">>)], children = lists:usort(XOpts)}]}, #adhoc_response{status = executing, defaultaction = "execute", @@ -1881,28 +1881,28 @@ send_authorization_request(#pubsub_node{owners = Owners, id = {Host, Node}}, Sub Lang = <<"en">>, %% TODO fix {U, S, R} = Subscriber, Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children = - [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR('type', <<"form">>)], children = + [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR(<<"type">>, <<"form">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "PubSub subscriber request"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'instructions', children = [#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Choose whether to approve this entity's subscription."))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"FORM_TYPE">>), ?XMLATTR('type', <<"hidden">>)], children = + [?XMLATTR(<<"var">>, <<"FORM_TYPE">>), ?XMLATTR(<<"type">>, <<"hidden">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(?NS_PUBSUB_SUBSCRIBE_AUTH_s)}]}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"pubsub#node">>), ?XMLATTR('type', <<"text-single">>), - ?XMLATTR('label', translate:translate(Lang, "Node ID"))], children = + [?XMLATTR(<<"var">>, <<"pubsub#node">>), ?XMLATTR(<<"type">>, <<"text-single">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, "Node ID"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = Node}]}]}, - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('var', <<"pubsub#subscriber_jid">>), - ?XMLATTR('type', <<"jid-single">>), - ?XMLATTR('label', translate:translate(Lang, "Subscriber Address"))], children = + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"var">>, <<"pubsub#subscriber_jid">>), + ?XMLATTR(<<"type">>, <<"jid-single">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, "Subscriber Address"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = exmpp_jid:to_binary(U, S, R)}]}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"pubsub#allow">>), - ?XMLATTR('type', <<"boolean">>), - ?XMLATTR('label', translate:translate(Lang, "Allow this Jabber ID to subscribe to this pubsub node?"))], children = + [?XMLATTR(<<"var">>, <<"pubsub#allow">>), + ?XMLATTR(<<"type">>, <<"boolean">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, "Allow this Jabber ID to subscribe to this pubsub node?"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"false">>}]}]}]}]}, lists:foreach(fun(Owner) -> {U, S, R} = Owner, @@ -1912,7 +1912,7 @@ send_authorization_request(#pubsub_node{owners = Owners, id = {Host, Node}}, Sub find_authorization_response(Packet) -> Els = Packet#xmlel.children, XData1 = lists:map(fun(#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = XAttrs} = XEl) -> - case exmpp_xml:get_attribute_from_list_as_list(XAttrs, 'type', "") of + case exmpp_xml:get_attribute_from_list_as_list(XAttrs, <<"type">>, "") of "cancel" -> none; _ -> @@ -1943,13 +1943,13 @@ find_authorization_response(Packet) -> %% @doc Send a message to JID with the supplied Subscription send_authorization_approval(Host, JID, SNode, Subscription) -> SubAttrs = case Subscription of - {S, SID} -> [?XMLATTR('subscription', subscription_to_string(S)), - ?XMLATTR('subid', SID)]; - S -> [?XMLATTR('subscription', subscription_to_string(S))] + {S, SID} -> [?XMLATTR(<<"subscription">>, subscription_to_string(S)), + ?XMLATTR(<<"subid">>, SID)]; + S -> [?XMLATTR(<<"subscription">>, subscription_to_string(S))] end, Stanza = event_stanza( [#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'subscription', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(JID)) | nodeAttr(SNode)] ++ SubAttrs + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(JID)) | nodeAttr(SNode)] ++ SubAttrs }]), ejabberd_router:route(service_jid(Host), JID, Stanza). @@ -2014,9 +2014,9 @@ update_auth(Host, Node, Type, Nidx, Subscriber, end. -define(XFIELD(Type, Label, Var, Val), - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type), - ?XMLATTR('label', translate:translate(Lang, Label)), - ?XMLATTR('var', Var)], children = + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"label">>, translate:translate(Lang, Label)), + ?XMLATTR(<<"var">>, Var)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Val)}]}]}). -define(BOOLXFIELD(Label, Var, Val), @@ -2032,17 +2032,17 @@ update_auth(Host, Node, Type, Nidx, Subscriber, -define(STRINGMXFIELD(Label, Var, Vals), #xmlel{ns = ?NS_DATA_FORMS, name = 'field', - attrs = [?XMLATTR('type', <<"text-multi">>), - ?XMLATTR('label', translate:translate(Lang, Label)), - ?XMLATTR('var', Var) + attrs = [?XMLATTR(<<"type">>, <<"text-multi">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, Label)), + ?XMLATTR(<<"var">>, Var) ], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [?XMLCDATA(V)]} || V <- Vals]}). -define(XFIELDOPT(Type, Label, Var, Val, Opts), - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type), - ?XMLATTR('label', translate:translate(Lang, Label)), - ?XMLATTR('var', Var)], children = + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"label">>, translate:translate(Lang, Label)), + ?XMLATTR(<<"var">>, Var)], children = lists:map(fun(Opt) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'option', children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = @@ -2054,9 +2054,9 @@ update_auth(Host, Node, Type, Nidx, Subscriber, ?XFIELDOPT("list-single", Label, Var, Val, Opts)). -define(LISTMXFIELD(Label, Var, Vals, Opts), - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', <<"list-multi">>), - ?XMLATTR('label', translate:translate(Lang, Label)), - ?XMLATTR('var', Var)], children = + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"type">>, <<"list-multi">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, Label)), + ?XMLATTR(<<"var">>, Var)], children = lists:map(fun(Opt) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'option', children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = @@ -2315,13 +2315,13 @@ subscribe_node(Host, Node, From, JID, Configuration) -> %% TODO, this is subscription-notification, should depends on node features SubAttrs = case Subscription of {subscribed, SubId} -> - [?XMLATTR("subscription", subscription_to_string(subscribed)), - ?XMLATTR("subid", SubId)]; + [?XMLATTR(<<"subscription">>, subscription_to_string(subscribed)), + ?XMLATTR(<<"subid">>, SubId)]; Other -> - [?XMLATTR("subscription", subscription_to_string(Other))] + [?XMLATTR(<<"subscription">>, subscription_to_string(Other))] end, Fields = - [ ?XMLATTR('jid', JID) | SubAttrs], + [ ?XMLATTR(<<"jid">>, JID) | SubAttrs], #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children = [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs = Fields}]} end, @@ -2796,8 +2796,8 @@ get_affiliations(Host, JID, Plugins) when is_list(Plugins) -> fun({_, none}) -> []; ({#pubsub_node{id = {_, Node}}, Affiliation}) -> [#xmlel{ns = ?NS_PUBSUB, name = 'affiliation', attrs = - [?XMLATTR('node', node_to_string(Node)), - ?XMLATTR('affiliation', affiliation_to_string(Affiliation))]}] + [?XMLATTR(<<"node">>, node_to_string(Node)), + ?XMLATTR(<<"affiliation">>, affiliation_to_string(Affiliation))]}] end, lists:usort(lists:flatten(Affiliations))), {result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children = [#xmlel{ns = ?NS_PUBSUB, name = 'affiliations', children = @@ -2827,8 +2827,8 @@ get_affiliations(Host, Node, JID) -> fun({_, none}) -> []; ({{AU, AS, AR}, Affiliation}) -> [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'affiliation', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(AU, AS, AR)), - ?XMLATTR('affiliation', affiliation_to_string(Affiliation))]}] + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(AU, AS, AR)), + ?XMLATTR(<<"affiliation">>, affiliation_to_string(Affiliation))]}] end, Affiliations), {result, #xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children = [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'affiliations', attrs = nodeAttr(Node), children = @@ -2850,12 +2850,12 @@ set_affiliations(Host, Node, From, EntitiesEls) -> #xmlel{name = 'affiliation', attrs = Attrs} -> JID = try exmpp_jid:parse( - exmpp_xml:get_attribute_from_list(Attrs, 'jid', "")) + exmpp_xml:get_attribute_from_list(Attrs, <<"jid">>, "")) catch _:_ -> error end, Affiliation = string_to_affiliation( - exmpp_xml:get_attribute_from_list_as_list(Attrs, 'affiliation', "")), + exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"affiliation">>, "")), if (JID == error) or (Affiliation == false) -> @@ -2958,8 +2958,8 @@ read_sub(Subscriber, Node, NodeId, SubId, Lang) -> {result, #pubsub_subscription{options = Options}} -> {result, XdataEl} = pubsub_subscription:get_options_xform(Lang, Options), OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options', - attrs = [ ?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)), - ?XMLATTR('subid', SubId) | nodeAttr(Node)], + attrs = [ ?XMLATTR(<<"jid">>, exmpp_jid:to_binary(Subscriber)), + ?XMLATTR(<<"subid">>, SubId) | nodeAttr(Node)], children = [XdataEl]}, PubsubEl = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children = [OptionsEl]}, {result, PubsubEl} @@ -3052,11 +3052,11 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) -> case Node of <<>> -> [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs = - [?XMLATTR('node', node_to_string(SubsNode)), - ?XMLATTR('subscription', subscription_to_string(Subscription))]}]; + [?XMLATTR(<<"node">>, node_to_string(SubsNode)), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription))]}]; SubsNode -> [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs = - [?XMLATTR('subscription', subscription_to_string(Subscription))]}]; + [?XMLATTR(<<"subscription">>, subscription_to_string(Subscription))]}]; _ -> [] end; @@ -3066,14 +3066,14 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) -> case Node of <<>> -> [#xmlel{ns = ?NS_PUBSUB, name='subscription', - attrs = [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)), - ?XMLATTR('subid', SubId), - ?XMLATTR('subscription', subscription_to_string(Subscription)) | nodeAttr(SubsNode)]}]; + attrs = [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(SubJID)), + ?XMLATTR(<<"subid">>, SubId), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription)) | nodeAttr(SubsNode)]}]; SubsNode -> [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', - attrs = [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)), - ?XMLATTR('subid', SubId), - ?XMLATTR('subscription', subscription_to_string(Subscription))]}]; + attrs = [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(SubJID)), + ?XMLATTR(<<"subid">>, SubId), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription))]}]; _ -> [] end; @@ -3081,13 +3081,13 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) -> case Node of <<>> -> [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs = - [?XMLATTR('node', node_to_string(SubsNode)), - ?XMLATTR('jid', exmpp_jid:to_binary(SubJID)), - ?XMLATTR('subscription', subscription_to_string(Subscription))]}]; + [?XMLATTR(<<"node">>, node_to_string(SubsNode)), + ?XMLATTR(<<"jid">>, exmpp_jid:to_binary(SubJID)), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription))]}]; SubsNode -> [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)), - ?XMLATTR('subscription', subscription_to_string(Subscription))]}]; + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(SubJID)), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription))]}]; _ -> [] end @@ -3124,13 +3124,13 @@ get_subscriptions(Host, Node, JID) -> ({_, pending, _}) -> []; ({{AU, AS, AR}, Subscription}) -> [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'subscription', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(AU, AS, AR)), - ?XMLATTR('subscription', subscription_to_string(Subscription))]}]; + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(AU, AS, AR)), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription))]}]; ({{AU, AS, AR}, Subscription, SubId}) -> [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'subscription', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(AU, AS, AR)), - ?XMLATTR('subscription', subscription_to_string(Subscription)), - ?XMLATTR('subid', SubId)]}] + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(AU, AS, AR)), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription)), + ?XMLATTR(<<"subid">>, SubId)]}] end, Subscriptions), {result, #xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children = [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'subscriptions', attrs = nodeAttr(Node), children = @@ -3152,14 +3152,14 @@ set_subscriptions(Host, Node, From, EntitiesEls) -> #xmlel{name = 'subscription', attrs = Attrs} -> JID = try exmpp_jid:parse( - exmpp_xml:get_attribute_from_list(Attrs, 'jid', "")) + exmpp_xml:get_attribute_from_list(Attrs, <<"jid">>, "")) catch _:_ -> error end, Subscription = string_to_subscription( - exmpp_xml:get_attribute_from_list_as_list(Attrs, 'subscription', false)), - SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, "subid", false), + exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"subscription">>, false)), + SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"subid">>, false), if (JID == error) or (Subscription == false) -> @@ -3183,8 +3183,8 @@ set_subscriptions(Host, Node, From, EntitiesEls) -> children = [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', - attrs = [?XMLATTR('jid', exmpp_jid:to_binary(JID)), - ?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]}, + attrs = [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(JID)), + ?XMLATTR(<<"subsription">>, subscription_to_string(Sub)) | nodeAttr(Node)]}]}]}, ejabberd_router:route(service_jid(Host), JID, Stanza) end, Action = fun(#pubsub_node{owners = Owners, type = Type, idx = Nidx}) -> @@ -3519,14 +3519,14 @@ broadcast_config_notification(Host, Node, NodeId, Type, NodeOptions, Lang) -> SubsByDepth when is_list(SubsByDepth) -> Content = case get_option(NodeOptions, deliver_payloads) of true -> - [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR('type', <<"form">>)], children = + [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR(<<"type">>, <<"form">>)], children = get_configure_xfields(Type, NodeOptions, Lang, [])}]; false -> [] end, Stanza = event_stanza( [#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'items', attrs = nodeAttr(Node), children = - [#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'item', attrs = [?XMLATTR('id', <<"configuration">>)], children = + [#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'item', attrs = [?XMLATTR(<<"id">>, <<"configuration">>)], children = Content}]}]), broadcast_stanza(Host, Node, NodeId, Type, NodeOptions, SubsByDepth, nodes, Stanza, false), {result, true}; @@ -3773,7 +3773,7 @@ get_configure(Host, ServerHost, Node, #jid{node = User, domain = Server} = From, [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'configure', attrs = nodeAttr(Node), children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = - [?XMLATTR('type', <<"form">>)], children = + [?XMLATTR(<<"type">>, <<"form">>)], children = get_configure_xfields(Type, Options, Lang, Groups) }]}]}}; _ -> @@ -3790,7 +3790,7 @@ get_default(Host, Node, _From, Lang) -> Options = node_options(Type), {result, #xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children = [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'default', children = - [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR('type', <<"form">>)], children = + [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR(<<"type">>, <<"form">>)], children = get_configure_xfields(Type, Options, Lang, []) }]}]}}. @@ -3947,7 +3947,7 @@ get_configure_xfields(_Type, Options, Lang, Groups) -> set_configure(Host, Node, From, Els, Lang) -> case exmpp_xml:remove_cdata_from_list(Els) of [#xmlel{ns = ?NS_DATA_FORMS, name = 'x'} = XEl] -> - case exmpp_xml:get_attribute_as_list(XEl, 'type', undefined) of + case exmpp_xml:get_attribute_as_list(XEl, <<"type">>, undefined) of "cancel" -> {result, []}; "submit" -> @@ -4476,7 +4476,7 @@ extended_error(Error, Ext) -> extended_error(Error, Ext, []). extended_error(Error, unsupported, Feature) -> extended_error(Error, unsupported, - [?XMLATTR('feature', Feature)]); + [?XMLATTR(<<"feature">>, Feature)]); extended_error(Error, Ext, ExtAttrs) -> %Pubsub_Err = #xmlel{ns = ?NS_PUBSUB_ERRORS, name = Ext, attrs = ExtAttrs}, exmpp_xml:append_child(exmpp_stanza:error(?NS_JABBER_CLIENT, Error), @@ -4491,13 +4491,13 @@ uniqid() -> % node attributes nodeAttr(Node) when is_list(Node) -> - [?XMLATTR('node', Node)]; + [?XMLATTR(<<"node">>, Node)]; nodeAttr(Node) -> - [?XMLATTR('node', node_to_string(Node))]. + [?XMLATTR(<<"node">>, node_to_string(Node))]. % item attributes itemAttr([]) -> []; -itemAttr(ItemId) -> [?XMLATTR('id', ItemId)]. +itemAttr(ItemId) -> [?XMLATTR(<<"id">>, ItemId)]. % build item elements from item list @@ -4545,19 +4545,19 @@ add_headers(#xmlel{children = Els} = Stanza, HeaderName, HeaderNS, HeaderEls) -> %% identifier of the collection". collection_shim(Node) -> [#xmlel{ns = ?NS_PUBSUB, name ='header', - attrs = [?XMLATTR('name', <<"Collection">>)], + attrs = [?XMLATTR(<<"name">>, <<"Collection">>)], children = [?XMLCDATA(node_to_string(Node))]}]. subid_shim(SubIds) -> [#xmlel{ns = ?NS_PUBSUB, name ='header', - attrs = [?XMLATTR('name', <<"SubId">>)], + attrs = [?XMLATTR(<<"name">>, <<"SubId">>)], children = [?XMLCDATA(SubId)]} || SubId <- SubIds]. extended_headers(JIDs) -> [#xmlel{ns = ?NS_ADDRESS, name = 'address', - attrs = [?XMLATTR('type', <<"replyto">>), ?XMLATTR('jid', JID)]} + attrs = [?XMLATTR(<<"type">>, <<"replyto">>), ?XMLATTR(<<"jid">>, JID)]} || JID <- JIDs]. feature_check_packet(allow, _User, Server, Pres, {From, _To, El}, in) -> @@ -4570,7 +4570,7 @@ feature_check_packet(allow, _User, Server, Pres, {From, _To, El}, in) -> case exmpp_xml:get_element(El, 'event') of #xmlel{name = 'event', ns = ?NS_PUBSUB_EVENT} = Event -> Items = exmpp_xml:get_element(Event, ?NS_PUBSUB_EVENT, 'items'), - Feature = exmpp_xml:get_attribute_as_list(Items, "node", ""), + Feature = exmpp_xml:get_attribute_as_list(Items, <<"node">>, ""), case is_feature_supported(Pres, Feature) of true -> allow; false -> deny @@ -4661,9 +4661,9 @@ notify_owners(true, JID, Host, Node, Owners, State) -> Message = #xmlel{name = 'message', ns = ?NS_JABBER_CLIENT, children = [#xmlel{name = 'pubsub', ns = ?NS_PUBSUB, children = [#xmlel{name = 'subscription', ns = ?NS_PUBSUB, - attrs = [?XMLATTR('node', Node), - ?XMLATTR('jid', exmpp_jid:prep_to_binary(exmpp_jid:make(JID))), - ?XMLATTR('subscription', State)]}]}]}, + attrs = [?XMLATTR(<<"node">>, Node), + ?XMLATTR(<<"jid">>, exmpp_jid:prep_to_binary(exmpp_jid:make(JID))), + ?XMLATTR(<<"subscription">>, State)]}]}]}, lists:foreach( fun(Owner) -> ejabberd_router:route(exmpp_jid:make(Host), exmpp_jid:make(Owner), Message) diff --git a/src/mod_pubsub/mod_pubsub_odbc.erl b/src/mod_pubsub/mod_pubsub_odbc.erl index f8b72155f..c0de02a7c 100644 --- a/src/mod_pubsub/mod_pubsub_odbc.erl +++ b/src/mod_pubsub/mod_pubsub_odbc.erl @@ -391,7 +391,7 @@ disco_local_identity(Acc, _From, To, <<>>, _Lang) -> case lists:member(?PEPNODE, plugins(exmpp_jid:prep_domain_as_list(To))) of true -> [#xmlel{name = 'identity', ns = ?NS_DISCO_INFO, - attrs = [?XMLATTR('category', <<"pubsub">>), ?XMLATTR('type', <<"pep">>)]} + attrs = [?XMLATTR(<<"category">>, <<"pubsub">>), ?XMLATTR(<<"type">>, <<"pep">>)]} | Acc]; false -> Acc end; @@ -420,7 +420,7 @@ disco_sm_identity(Acc, From, To, Node, _Lang) -> disco_identity(_Host, <<>>, _From) -> [#xmlel{name = 'identity', ns = ?NS_DISCO_INFO, - attrs = [?XMLATTR('category', <<"pubsub">>), ?XMLATTR('type', <<"pep">>)]}]; + attrs = [?XMLATTR(<<"category">>, <<"pubsub">>), ?XMLATTR(<<"type">>, <<"pep">>)]}]; disco_identity(Host, Node, From) -> Action = fun(#pubsub_node{idx = Nidx, type = Type, options = Options}) -> Owners = node_owners_call(Type, Nidx), @@ -428,12 +428,12 @@ disco_identity(Host, Node, From) -> {result, _} -> {result, [#xmlel{name = 'identity', ns = ?NS_DISCO_INFO, - attrs = [?XMLATTR('category', <<"pubsub">>), ?XMLATTR('type', <<"pep">>)]}, + attrs = [?XMLATTR(<<"category">>, <<"pubsub">>), ?XMLATTR(<<"type">>, <<"pep">>)]}, #xmlel{name = 'identity', ns = ?NS_DISCO_INFO, - attrs = [?XMLATTR('category', <<"pubsub">>), ?XMLATTR('type', <<"leaf">>) + attrs = [?XMLATTR(<<"category">>, <<"pubsub">>), ?XMLATTR(<<"type">>, <<"leaf">>) | case get_option(Options, title) of false -> []; - Title -> [?XMLATTR('name', Title)] + Title -> [?XMLATTR(<<"name">>, Title)] end ]}]}; {error, _} -> {result, []} @@ -479,11 +479,11 @@ disco_items(Host, <<>>, From) -> case get_allowed_items_call(Host, Nidx, From, Type, Options, Owners) of {result, _} -> [#xmlel{name = 'item', ns = ?NS_DISCO_INFO, - attrs = [?XMLATTR('jid', exmpp_jid:to_binary(Host)), - ?XMLATTR('node', NodeId) | + attrs = [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(Host)), + ?XMLATTR(<<"node">>, NodeId) | case get_option(Options, title) of false -> []; - [Title] -> [?XMLATTR('title', Title)] + [Title] -> [?XMLATTR(<<"title">>, Title)] end]} | Acc]; _ -> Acc @@ -501,8 +501,8 @@ disco_items(Host, Node, From) -> {result, Items} -> {result, [#xmlel{name = 'item', ns = ?NS_DISCO_INFO, - attrs = [?XMLATTR('jid', exmpp_jid:to_binary(Host)), - ?XMLATTR('name', ItemId)]} + attrs = [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(Host)), + ?XMLATTR(<<"name">>, ItemId)]} || #pubsub_item{id = {ItemId,_}} <- Items]}; _ -> {result, []} end @@ -744,7 +744,7 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) -> #iq{type = get, ns = ?NS_DISCO_INFO, payload = SubEl, lang = Lang} -> QAttrs = SubEl#xmlel.attrs, - Node = exmpp_xml:get_attribute_from_list_as_list(QAttrs, 'node', ""), + Node = exmpp_xml:get_attribute_from_list_as_list(QAttrs, <<"node">>, ""), ServerHostB = list_to_binary(ServerHost), Info = ejabberd_hooks:run_fold( disco_info, ServerHostB, [], @@ -762,7 +762,7 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) -> #iq{type = get, ns = ?NS_DISCO_ITEMS, payload = SubEl} = IQ -> QAttrs = SubEl#xmlel.attrs, - Node = exmpp_xml:get_attribute_from_list_as_list(QAttrs, 'node', ""), + Node = exmpp_xml:get_attribute_from_list_as_list(QAttrs, <<"node">>, ""), Rsm = jlib:rsm_decode(IQ), Res = case iq_disco_items(Host, Node, From, Rsm) of {result, IQRes} -> @@ -838,12 +838,12 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) -> undefined -> ok; Publish -> - Node = exmpp_xml:get_attribute(Publish, 'node', <<>>), + Node = exmpp_xml:get_attribute(Publish, <<"node">>, <<>>), case exmpp_xml:get_element(Publish, 'item') of undefined -> ok; Item -> - ItemId = exmpp_xml:get_attribute_as_list(Item, 'id', ""), + ItemId = exmpp_xml:get_attribute_as_list(Item, <<"id">>, ""), case publish_item(Host, ServerHost, Node, From, ItemId, Item#xmlel.children) of {result, _} -> ok; @@ -875,16 +875,16 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) -> command_disco_info(_Host, ?NS_ADHOC_b, _From) -> IdentityEl = #xmlel{ns = ?NS_DISCO_INFO, name = 'identity', - attrs = [?XMLATTR('category', <<"automation">>), - ?XMLATTR('type', <<"command-list">>)]}, + attrs = [?XMLATTR(<<"category">>, <<"automation">>), + ?XMLATTR(<<"type">>, <<"command-list">>)]}, {result, [IdentityEl]}; command_disco_info(_Host, ?NS_PUBSUB_GET_PENDING_b, _From) -> IdentityEl = #xmlel{ns = ?NS_DISCO_INFO, name = 'identity', - attrs = [?XMLATTR('category', <<"automation">>), - ?XMLATTR('type', <<"command-node">>)]}, + attrs = [?XMLATTR(<<"category">>, <<"automation">>), + ?XMLATTR(<<"type">>, <<"command-node">>)]}, FeaturesEl = #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', - attrs = [?XMLATTR('var', ?NS_ADHOC)]}, + attrs = [?XMLATTR(<<"var">>, ?NS_ADHOC)]}, {result, [IdentityEl, FeaturesEl]}. node_disco_info(Host, Node, From) -> @@ -908,18 +908,18 @@ node_disco_info(Host, Node, From, Identity, Features) -> end end, lists:map(fun(T) -> - #xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = [?XMLATTR('category', <<"pubsub">>), - ?XMLATTR('type', T)]} + #xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = [?XMLATTR(<<"category">>, <<"pubsub">>), + ?XMLATTR(<<"type">>, T)]} end, Types) end, F = case Features of false -> []; true -> - [#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]} | + [#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_s)]} | lists:map(fun - ("rsm") -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_RSM_s)]}; - (T) -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++T)]} + ("rsm") -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_RSM_s)]}; + (T) -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_s++"#"++T)]} end, features(Type))] end, %% TODO: add meta-data info (spec section 5.4) @@ -940,17 +940,17 @@ iq_disco_info(Host, SNode, From, Lang) -> <<>> -> {result, [#xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = - [?XMLATTR('category', "pubsub"), - ?XMLATTR('type', "service"), - ?XMLATTR('name', translate:translate(Lang, "Publish-Subscribe"))]}, - #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_INFO_s)]}, - #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_ITEMS_s)]}, - #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]}, - #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_ADHOC_s)]}, - #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++ + [?XMLATTR(<<"category">>, "pubsub"), + ?XMLATTR(<<"type">>, "service"), + ?XMLATTR(<<"name">>, translate:translate(Lang, "Publish-Subscribe"))]}, + #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_DISCO_INFO_s)]}, + #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_DISCO_ITEMS_s)]}, + #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_s)]}, + #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_ADHOC_s)]}, + #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_VCARD_s)]}] ++ lists:map(fun - ("rsm") -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_RSM_s)]}; - (Feature) -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++Feature)]} + ("rsm") -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_RSM_s)]}; + (Feature) -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_s++"#"++Feature)]} end, features(Host, Node))}; ?NS_ADHOC_b -> command_disco_info(Host, Node, From); @@ -968,9 +968,9 @@ iq_disco_items(Host, [], From, _RSM) -> Attrs = case get_option(Options, title) of false -> - [?XMLATTR('jid', Host) | nodeAttr(SubNode)]; + [?XMLATTR(<<"jid">>, Host) | nodeAttr(SubNode)]; Title -> - [?XMLATTR('jid', Host), ?XMLATTR('name', Title) | nodeAttr(SubNode)] + [?XMLATTR(<<"jid">>, Host), ?XMLATTR(<<"name">>, Title) | nodeAttr(SubNode)] end, #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = Attrs} end, Nodes)}; @@ -981,9 +981,9 @@ iq_disco_items(Host, ?NS_ADHOC_s, _From, _RSM) -> %% TODO: support localization of this string CommandItems = [ #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', - attrs = [?XMLATTR('jid', Host), - ?XMLATTR('node', ?NS_PUBSUB_GET_PENDING), - ?XMLATTR('name', "Get Pending") + attrs = [?XMLATTR(<<"jid">>, Host), + ?XMLATTR(<<"node">>, ?NS_PUBSUB_GET_PENDING), + ?XMLATTR(<<"name">>, "Get Pending") ]}], {result, CommandItems}; iq_disco_items(_Host, ?NS_PUBSUB_GET_PENDING, _From, _RSM) -> @@ -1006,16 +1006,16 @@ iq_disco_items(Host, Item, From, RSM) -> Attrs = case get_option(SubOptions, title) of false -> - [?XMLATTR('jid', Host) | nodeAttr(SubNode)]; + [?XMLATTR(<<"jid">>, Host) | nodeAttr(SubNode)]; Title -> - [?XMLATTR('jid', Host), ?XMLATTR('name', Title) | nodeAttr(SubNode)] + [?XMLATTR(<<"jid">>, Host), ?XMLATTR(<<"name">>, Title) | nodeAttr(SubNode)] end, #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = Attrs} end, tree_call(Host, get_subnodes, [Host, Node, From])), Items = lists:map( fun(#pubsub_item{id = {RN, _}}) -> {result, Name} = node_call(Type, get_item_name, [Host, Node, RN]), - #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host), ?XMLATTR('name', Name)]} + #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR(<<"jid">>, Host), ?XMLATTR(<<"name">>, Name)]} end, NodeItems), {result, Nodes ++ Items ++ jlib:rsm_encode(RsmOut)} end, @@ -1067,7 +1067,7 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) -> case exmpp_xml:remove_cdata_from_list(SubEl#xmlel.children) of [#xmlel{name = Name, attrs = Attrs, children = Els} | Rest] -> %% Fix bug when owner retrieves his affiliations - Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', "")), + Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"node">>, "")), case {IQType, Name} of {set, 'create'} -> Config = case Rest of @@ -1075,7 +1075,7 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) -> _ -> [] end, %% Get the type of the node - Type = case exmpp_xml:get_attribute_from_list_as_list(Attrs, 'type', "") of + Type = case exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"type">>, "") of [] -> hd(Plugins); T -> T end, @@ -1093,7 +1093,7 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) -> {set, 'publish'} -> case exmpp_xml:remove_cdata_from_list(Els) of [#xmlel{name = 'item', attrs = ItemAttrs, children = Payload}] -> - ItemId = exmpp_xml:get_attribute_from_list_as_list(ItemAttrs, 'id', ""), + ItemId = exmpp_xml:get_attribute_from_list_as_list(ItemAttrs, <<"id">>, ""), publish_item(Host, ServerHost, Node, From, ItemId, Payload); [] -> %% Publisher attempts to publish to persistent node with no item @@ -1105,14 +1105,14 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) -> "invalid-payload")} end; {set, 'retract'} -> - ForceNotify = case exmpp_xml:get_attribute_from_list_as_list(Attrs, 'notify', "") of + ForceNotify = case exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"notify">>, "") of "1" -> true; "true" -> true; _ -> false end, case exmpp_xml:remove_cdata_from_list(Els) of [#xmlel{name = 'item', attrs = ItemAttrs}] -> - ItemId = exmpp_xml:get_attribute_from_list_as_list(ItemAttrs, 'id', ""), + ItemId = exmpp_xml:get_attribute_from_list_as_list(ItemAttrs, <<"id">>, ""), delete_item(Host, Node, From, ItemId, ForceNotify); _ -> %% Request does not specify an item @@ -1124,18 +1124,18 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) -> [#xmlel{name = 'options', children = C}] -> C; _ -> [] end, - JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""), + JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"jid">>, ""), subscribe_node(Host, Node, From, JID, Config); {set, 'unsubscribe'} -> - JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""), - SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'subid', ""), + JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"jid">>, ""), + SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"subid">>, ""), unsubscribe_node(Host, Node, From, JID, SubId); {get, 'items'} -> - MaxItems = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'max_items', ""), - SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'subid', ""), + MaxItems = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"max_items">>, ""), + SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"subid">>, ""), ItemIds = lists:foldl(fun (#xmlel{name = 'item', attrs = ItemAttrs}, Acc) -> - case exmpp_xml:get_attribute_from_list_as_list(ItemAttrs, 'id', "") of + case exmpp_xml:get_attribute_from_list_as_list(ItemAttrs, <<"id">>, "") of "" -> Acc; ItemId -> [ItemId|Acc] end; @@ -1148,12 +1148,12 @@ iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) -> {get, 'affiliations'} -> get_affiliations(Host, From, Plugins); {get, 'options'} -> - SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'subid', ""), - JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""), + SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"subid">>, ""), + JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"jid">>, ""), get_options(Host, Node, JID, SubId, Lang); {set, 'options'} -> - SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'subid', ""), - JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, 'jid', ""), + SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"subid">>, ""), + JID = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"jid">>, ""), set_options(Host, Node, JID, SubId, Els); _ -> {error, 'feature-not-implemented'} @@ -1168,7 +1168,7 @@ iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) -> Action = exmpp_xml:remove_cdata_from_list(SubEls), case Action of [#xmlel{name = Name, attrs = Attrs, children = Els}] -> - Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', "")), + Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"node">>, "")), case {IQType, Name} of {get, 'configure'} -> get_configure(Host, ServerHost, Node, From, Lang); @@ -1280,11 +1280,11 @@ send_pending_node_form(Host, Owner, _Lang, Plugins) -> children = [ exmpp_xml:cdata(node_to_string(Node))]}]} end, get_pending_nodes(Host, Owner, Ps)), - XForm = #xmlel{ns = ?NS_DATA_FORMS, name ='x', attrs = [?XMLATTR('type', <<"form">>)], + XForm = #xmlel{ns = ?NS_DATA_FORMS, name ='x', attrs = [?XMLATTR(<<"type">>, <<"form">>)], children = [ #xmlel{ns = ?NS_DATA_FORMS, name = 'field', - attrs = [?XMLATTR('type', <<"list-single">>), - ?XMLATTR('var', <<"pubsub#node">>)], + attrs = [?XMLATTR(<<"type">>, <<"list-single">>), + ?XMLATTR(<<"var">>, <<"pubsub#node">>)], children = lists:usort(XOpts)}]}, #adhoc_response{status = executing, defaultaction = "execute", @@ -1348,28 +1348,28 @@ send_authorization_request(#pubsub_node{id = {Host, Node}, type = Type, idx = Ni Lang = <<"en">>, %% TODO fix {U, S, R} = Subscriber, Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children = - [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR('type', <<"form">>)], children = + [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR(<<"type">>, <<"form">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "PubSub subscriber request"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'instructions', children = [#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Choose whether to approve this entity's subscription."))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"FORM_TYPE">>), ?XMLATTR('type', <<"hidden">>)], children = + [?XMLATTR(<<"var">>, <<"FORM_TYPE">>), ?XMLATTR(<<"type">>, <<"hidden">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(?NS_PUBSUB_SUBSCRIBE_AUTH_s)}]}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"pubsub#node">>), ?XMLATTR('type', <<"text-single">>), - ?XMLATTR('label', translate:translate(Lang, "Node ID"))], children = + [?XMLATTR(<<"var">>, <<"pubsub#node">>), ?XMLATTR(<<"type">>, <<"text-single">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, "Node ID"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = Node}]}]}, - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('var', <<"pubsub#subscriber_jid">>), - ?XMLATTR('type', <<"jid-single">>), - ?XMLATTR('label', translate:translate(Lang, "Subscriber Address"))], children = + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"var">>, <<"pubsub#subscriber_jid">>), + ?XMLATTR(<<"type">>, <<"jid-single">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, "Subscriber Address"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = exmpp_jid:to_binary(U, S, R)}]}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"pubsub#allow">>), - ?XMLATTR('type', <<"boolean">>), - ?XMLATTR('label', translate:translate(Lang, "Allow this Jabber ID to subscribe to this pubsub node?"))], children = + [?XMLATTR(<<"var">>, <<"pubsub#allow">>), + ?XMLATTR(<<"type">>, <<"boolean">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, "Allow this Jabber ID to subscribe to this pubsub node?"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = <<"false">>}]}]}]}]}, lists:foreach(fun(Owner) -> {U, S, R} = Owner, @@ -1379,7 +1379,7 @@ send_authorization_request(#pubsub_node{id = {Host, Node}, type = Type, idx = Ni find_authorization_response(Packet) -> Els = Packet#xmlel.children, XData1 = lists:map(fun(#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = XAttrs} = XEl) -> - case exmpp_xml:get_attribute_from_list_as_list(XAttrs, 'type', "") of + case exmpp_xml:get_attribute_from_list_as_list(XAttrs, <<"type">>, "") of "cancel" -> none; _ -> @@ -1410,13 +1410,13 @@ find_authorization_response(Packet) -> %% @doc Send a message to JID with the supplied Subscription send_authorization_approval(Host, JID, SNode, Subscription) -> SubAttrs = case Subscription of - {S, SID} -> [?XMLATTR('subscription', subscription_to_string(S)), - ?XMLATTR('subid', SID)]; - S -> [?XMLATTR('subscription', subscription_to_string(S))] + {S, SID} -> [?XMLATTR(<<"subscription">>, subscription_to_string(S)), + ?XMLATTR(<<"subid">>, SID)]; + S -> [?XMLATTR(<<"subscription">>, subscription_to_string(S))] end, Stanza = event_stanza( [#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'subscription', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(JID)) | nodeAttr(SNode)] ++ SubAttrs + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(JID)) | nodeAttr(SNode)] ++ SubAttrs }]), ejabberd_router:route(service_jid(Host), JID, Stanza). @@ -1481,9 +1481,9 @@ update_auth(Host, Node, Type, Nidx, Subscriber, end. -define(XFIELD(Type, Label, Var, Val), - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type), - ?XMLATTR('label', translate:translate(Lang, Label)), - ?XMLATTR('var', Var)], children = + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"label">>, translate:translate(Lang, Label)), + ?XMLATTR(<<"var">>, Var)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = list_to_binary(Val)}]}]}). -define(BOOLXFIELD(Label, Var, Val), @@ -1499,17 +1499,17 @@ update_auth(Host, Node, Type, Nidx, Subscriber, -define(STRINGMXFIELD(Label, Var, Vals), #xmlel{ns = ?NS_DATA_FORMS, name = 'field', - attrs = [?XMLATTR('type', <<"text-multi">>), - ?XMLATTR('label', translate:translate(Lang, Label)), - ?XMLATTR('var', Var) + attrs = [?XMLATTR(<<"type">>, <<"text-multi">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, Label)), + ?XMLATTR(<<"var">>, Var) ], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [?XMLCDATA(V)]} || V <- Vals]}). -define(XFIELDOPT(Type, Label, Var, Val, Opts), - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', Type), - ?XMLATTR('label', translate:translate(Lang, Label)), - ?XMLATTR('var', Var)], children = + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"label">>, translate:translate(Lang, Label)), + ?XMLATTR(<<"var">>, Var)], children = lists:map(fun(Opt) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'option', children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = @@ -1521,9 +1521,9 @@ update_auth(Host, Node, Type, Nidx, Subscriber, ?XFIELDOPT("list-single", Label, Var, Val, Opts)). -define(LISTMXFIELD(Label, Var, Vals, Opts), - #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR('type', <<"list-multi">>), - ?XMLATTR('label', translate:translate(Lang, Label)), - ?XMLATTR('var', Var)], children = + #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = [?XMLATTR(<<"type">>, <<"list-multi">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, Label)), + ?XMLATTR(<<"var">>, Var)], children = lists:map(fun(Opt) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'option', children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = @@ -1783,13 +1783,13 @@ subscribe_node(Host, Node, From, JID, Configuration) -> %% TODO, this is subscription-notification, should depends on node features SubAttrs = case Subscription of {subscribed, SubId} -> - [?XMLATTR("subscription", subscription_to_string(subscribed)), - ?XMLATTR("subid", SubId)]; + [?XMLATTR(<<"subscription">>, subscription_to_string(subscribed)), + ?XMLATTR(<<"subid">>, SubId)]; Other -> - [?XMLATTR("subscription", subscription_to_string(Other))] + [?XMLATTR(<<"subscription">>, subscription_to_string(Other))] end, Fields = - [ ?XMLATTR('jid', JID) | SubAttrs], + [ ?XMLATTR(<<"jid">>, JID) | SubAttrs], #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children = [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs = Fields}]} end, @@ -2271,8 +2271,8 @@ get_affiliations(Host, JID, Plugins) when is_list(Plugins) -> fun({_, none}) -> []; ({#pubsub_node{id = {_, Node}}, Affiliation}) -> [#xmlel{ns = ?NS_PUBSUB, name = 'affiliation', attrs = - [?XMLATTR('node', node_to_string(Node)), - ?XMLATTR('affiliation', affiliation_to_string(Affiliation))]}] + [?XMLATTR(<<"node">>, node_to_string(Node)), + ?XMLATTR(<<"affiliation">>, affiliation_to_string(Affiliation))]}] end, lists:usort(lists:flatten(Affiliations))), {result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children = [#xmlel{ns = ?NS_PUBSUB, name = 'affiliations', children = @@ -2302,8 +2302,8 @@ get_affiliations(Host, Node, JID) -> fun({_, none}) -> []; ({{AU, AS, AR}, Affiliation}) -> [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'affiliation', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(AU, AS, AR)), - ?XMLATTR('affiliation', affiliation_to_string(Affiliation))]}] + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(AU, AS, AR)), + ?XMLATTR(<<"affiliation">>, affiliation_to_string(Affiliation))]}] end, Affiliations), {result, #xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children = [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'affiliations', attrs = nodeAttr(Node), children = @@ -2325,12 +2325,12 @@ set_affiliations(Host, Node, From, EntitiesEls) -> #xmlel{name = 'affiliation', attrs = Attrs} -> JID = try exmpp_jid:parse( - exmpp_xml:get_attribute_from_list(Attrs, 'jid', "")) + exmpp_xml:get_attribute_from_list(Attrs, <<"jid">>, "")) catch _:_ -> error end, Affiliation = string_to_affiliation( - exmpp_xml:get_attribute_from_list_as_list(Attrs, 'affiliation', "")), + exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"affiliation">>, "")), if (JID == error) or (Affiliation == false) -> @@ -2418,8 +2418,8 @@ read_sub(Subscriber, Node, NodeId, SubId, Lang) -> {result, #pubsub_subscription{options = Options}} -> {result, XdataEl} = pubsub_subscription_odbc:get_options_xform(Lang, Options), OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options', - attrs = [ ?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)), - ?XMLATTR('subid', SubId) | nodeAttr(Node)], + attrs = [ ?XMLATTR(<<"jid">>, exmpp_jid:to_binary(Subscriber)), + ?XMLATTR(<<"subid">>, SubId) | nodeAttr(Node)], children = [XdataEl]}, PubsubEl = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children = [OptionsEl]}, {result, PubsubEl} @@ -2512,11 +2512,11 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) -> case Node of <<>> -> [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs = - [?XMLATTR('node', node_to_string(SubsNode)), - ?XMLATTR('subscription', subscription_to_string(Subscription))]}]; + [?XMLATTR(<<"node">>, node_to_string(SubsNode)), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription))]}]; SubsNode -> [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs = - [?XMLATTR('subscription', subscription_to_string(Subscription))]}]; + [?XMLATTR(<<"subscription">>, subscription_to_string(Subscription))]}]; _ -> [] end; @@ -2526,14 +2526,14 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) -> case Node of <<>> -> [#xmlel{ns = ?NS_PUBSUB, name='subscription', - attrs = [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)), - ?XMLATTR('subid', SubId), - ?XMLATTR('subscription', subscription_to_string(Subscription)) | nodeAttr(SubsNode)]}]; + attrs = [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(SubJID)), + ?XMLATTR(<<"subid">>, SubId), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription)) | nodeAttr(SubsNode)]}]; SubsNode -> [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', - attrs = [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)), - ?XMLATTR('subid', SubId), - ?XMLATTR('subscription', subscription_to_string(Subscription))]}]; + attrs = [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(SubJID)), + ?XMLATTR(<<"subid">>, SubId), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription))]}]; _ -> [] end; @@ -2541,13 +2541,13 @@ get_subscriptions(Host, Node, JID, Plugins) when is_list(Plugins) -> case Node of <<>> -> [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs = - [?XMLATTR('node', node_to_string(SubsNode)), - ?XMLATTR('jid', exmpp_jid:to_binary(SubJID)), - ?XMLATTR('subscription', subscription_to_string(Subscription))]}]; + [?XMLATTR(<<"node">>, node_to_string(SubsNode)), + ?XMLATTR(<<"jid">>, exmpp_jid:to_binary(SubJID)), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription))]}]; SubsNode -> [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(SubJID)), - ?XMLATTR('subscription', subscription_to_string(Subscription))]}]; + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(SubJID)), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription))]}]; _ -> [] end @@ -2584,13 +2584,13 @@ get_subscriptions(Host, Node, JID) -> ({_, pending, _}) -> []; ({{AU, AS, AR}, Subscription}) -> [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'subscription', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(AU, AS, AR)), - ?XMLATTR('subscription', subscription_to_string(Subscription))]}]; + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(AU, AS, AR)), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription))]}]; ({{AU, AS, AR}, Subscription, SubId}) -> [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'subscription', attrs = - [?XMLATTR('jid', exmpp_jid:to_binary(AU, AS, AR)), - ?XMLATTR('subscription', subscription_to_string(Subscription)), - ?XMLATTR('subid', SubId)]}] + [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(AU, AS, AR)), + ?XMLATTR(<<"subscription">>, subscription_to_string(Subscription)), + ?XMLATTR(<<"subid">>, SubId)]}] end, Subscriptions), {result, #xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children = [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'subscriptions', attrs = nodeAttr(Node), children = @@ -2612,14 +2612,14 @@ set_subscriptions(Host, Node, From, EntitiesEls) -> #xmlel{name = 'subscription', attrs = Attrs} -> JID = try exmpp_jid:parse( - exmpp_xml:get_attribute_from_list(Attrs, 'jid', "")) + exmpp_xml:get_attribute_from_list(Attrs, <<"jid">>, "")) catch _:_ -> error end, Subscription = string_to_subscription( - exmpp_xml:get_attribute_from_list_as_list(Attrs, 'subscription', false)), - SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, "subid", false), + exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"subscription">>, false)), + SubId = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"subid">>, false), if (JID == error) or (Subscription == false) -> @@ -2643,8 +2643,8 @@ set_subscriptions(Host, Node, From, EntitiesEls) -> children = [#xmlel{ns = ?NS_PUBSUB, name = 'subscription', - attrs = [?XMLATTR('jid', exmpp_jid:to_binary(JID)), - ?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]}, + attrs = [?XMLATTR(<<"jid">>, exmpp_jid:to_binary(JID)), + ?XMLATTR(<<"subsription">>, subscription_to_string(Sub)) | nodeAttr(Node)]}]}]}, ejabberd_router:route(service_jid(Host), JID, Stanza) end, Action = fun(#pubsub_node{type = Type, idx = Nidx}) -> @@ -2973,14 +2973,14 @@ broadcast_config_notification(Host, Node, NodeId, Type, NodeOptions, Lang) -> SubsByDepth when is_list(SubsByDepth) -> Content = case get_option(NodeOptions, deliver_payloads) of true -> - [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR('type', <<"form">>)], children = + [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR(<<"type">>, <<"form">>)], children = get_configure_xfields(Type, NodeOptions, Lang, [])}]; false -> [] end, Stanza = event_stanza( [#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'items', attrs = nodeAttr(Node), children = - [#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'item', attrs = [?XMLATTR('id', <<"configuration">>)], children = + [#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'item', attrs = [?XMLATTR(<<"id">>, <<"configuration">>)], children = Content}]}]), broadcast_stanza(Host, Node, NodeId, Type, NodeOptions, SubsByDepth, nodes, Stanza, false), {result, true}; @@ -3191,7 +3191,7 @@ get_configure(Host, ServerHost, Node, From, Lang) -> [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'configure', attrs = nodeAttr(Node), children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = - [?XMLATTR('type', <<"form">>)], children = + [?XMLATTR(<<"type">>, <<"form">>)], children = get_configure_xfields(Type, Options, Lang, Groups) }]}]}}; _ -> @@ -3208,7 +3208,7 @@ get_default(Host, Node, _From, Lang) -> Options = node_options(Type), {result, #xmlel{ns = ?NS_PUBSUB_OWNER, name = 'pubsub', children = [#xmlel{ns = ?NS_PUBSUB_OWNER, name = 'default', children = - [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR('type', <<"form">>)], children = + [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR(<<"type">>, <<"form">>)], children = get_configure_xfields(Type, Options, Lang, []) }]}]}}. @@ -3359,7 +3359,7 @@ get_configure_xfields(_Type, Options, Lang, Groups) -> set_configure(Host, Node, From, Els, Lang) -> case exmpp_xml:remove_cdata_from_list(Els) of [#xmlel{ns = ?NS_DATA_FORMS, name = 'x'} = XEl] -> - case exmpp_xml:get_attribute_as_list(XEl, 'type', undefined) of + case exmpp_xml:get_attribute_as_list(XEl, <<"type">>, undefined) of "cancel" -> {result, []}; "submit" -> @@ -3761,7 +3761,7 @@ extended_error(Error, Ext) -> extended_error(Error, Ext, []). extended_error(Error, unsupported, Feature) -> extended_error(Error, unsupported, - [?XMLATTR('feature', Feature)]); + [?XMLATTR(<<"feature">>, Feature)]); extended_error(Error, Ext, ExtAttrs) -> Pubsub_Err = #xmlel{ns = ?NS_PUBSUB_ERRORS, name = Ext, attrs = ExtAttrs}, exmpp_xml:append_child(exmpp_stanza:error(?NS_JABBER_CLIENT, Error), @@ -3774,13 +3774,13 @@ uniqid() -> % node attributes nodeAttr(Node) when is_list(Node) -> - [?XMLATTR('node', Node)]; + [?XMLATTR(<<"node">>, Node)]; nodeAttr(Node) -> - [?XMLATTR('node', node_to_string(Node))]. + [?XMLATTR(<<"node">>, node_to_string(Node))]. % item attributes itemAttr([]) -> []; -itemAttr(ItemId) -> [?XMLATTR('id', ItemId)]. +itemAttr(ItemId) -> [?XMLATTR(<<"id">>, ItemId)]. % build item elements from item list itemsEls(Items) -> @@ -3821,19 +3821,19 @@ add_headers(#xmlel{children = Els} = Stanza, HeaderName, HeaderNS, HeaderEls) -> %% identifier of the collection". collection_shim(Node) -> [#xmlel{ns = ?NS_PUBSUB, name ='header', - attrs = [?XMLATTR('name', <<"Collection">>)], + attrs = [?XMLATTR(<<"name">>, <<"Collection">>)], children = [?XMLCDATA(node_to_string(Node))]}]. subid_shim(SubIds) -> [#xmlel{ns = ?NS_PUBSUB, name ='header', - attrs = [?XMLATTR('name', <<"SubId">>)], + attrs = [?XMLATTR(<<"name">>, <<"SubId">>)], children = [?XMLCDATA(SubId)]} || SubId <- SubIds]. extended_headers(JIDs) -> [#xmlel{ns = ?NS_ADDRESS, name = 'address', - attrs = [?XMLATTR('type', <<"replyto">>), ?XMLATTR('jid', JID)]} + attrs = [?XMLATTR(<<"type">>, <<"replyto">>), ?XMLATTR(<<"jid">>, JID)]} || JID <- JIDs]. feature_check_packet(allow, _User, Server, Pres, {From, _To, El}, in) -> @@ -3846,7 +3846,7 @@ feature_check_packet(allow, _User, Server, Pres, {From, _To, El}, in) -> case exmpp_xml:get_element(El, 'event') of #xmlel{name = 'event', ns = ?NS_PUBSUB_EVENT} = Event -> Items = exmpp_xml:get_element(Event, ?NS_PUBSUB_EVENT, 'items'), - Feature = exmpp_xml:get_attribute_as_list(Items, "node", ""), + Feature = exmpp_xml:get_attribute_as_list(Items, <<"node">>, ""), case is_feature_supported(Pres, Feature) of true -> allow; false -> deny @@ -3937,9 +3937,9 @@ notify_owners(true, JID, Host, Node, Owners, State) -> Message = #xmlel{name = 'message', ns = ?NS_JABBER_CLIENT, children = [#xmlel{name = 'pubsub', ns = ?NS_PUBSUB, children = [#xmlel{name = 'subscription', ns = ?NS_PUBSUB, - attrs = [?XMLATTR('node', Node), - ?XMLATTR('jid', exmpp_jid:prep_to_binary(exmpp_jid:make(JID))), - ?XMLATTR('subscription', State)]}]}]}, + attrs = [?XMLATTR(<<"node">>, Node), + ?XMLATTR(<<"jid">>, exmpp_jid:prep_to_binary(exmpp_jid:make(JID))), + ?XMLATTR(<<"subscription">>, State)]}]}]}, lists:foreach( fun(Owner) -> ejabberd_router:route(exmpp_jid:make(Host), exmpp_jid:make(Owner), Message) diff --git a/src/mod_pubsub/pubsub_odbc.patch b/src/mod_pubsub/pubsub_odbc.patch index 5309386ff..82c2a0d15 100644 --- a/src/mod_pubsub/pubsub_odbc.patch +++ b/src/mod_pubsub/pubsub_odbc.patch @@ -276,7 +276,7 @@ if (SubJID == LJID) or (SubJID == BJID) -> @@ -616,7 +422,8 @@ [#xmlel{name = 'identity', ns = ?NS_DISCO_INFO, - attrs = [?XMLATTR('category', <<"pubsub">>), ?XMLATTR('type', <<"pep">>)]}]; + attrs = [?XMLATTR(<<"category">>, <<"pubsub">>), ?XMLATTR('type', <<"pep">>)]}]; disco_identity(Host, Node, From) -> - Action = fun(#pubsub_node{idx = Nidx, type = Type, options = Options, owners = Owners}) -> + Action = fun(#pubsub_node{idx = Nidx, type = Type, options = Options}) -> @@ -360,24 +360,24 @@ @@ -1106,8 +917,9 @@ []; true -> - [#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]} | + [#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_s)]} | - lists:map(fun(T) -> -- #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++T)]} +- #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_s++"#"++T)]} + lists:map(fun -+ ("rsm") -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_RSM_s)]}; -+ (T) -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++T)]} ++ ("rsm") -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_RSM_s)]}; ++ (T) -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_s++"#"++T)]} end, features(Type))] end, %% TODO: add meta-data info (spec section 5.4) @@ -1136,8 +948,9 @@ - #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]}, - #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_ADHOC_s)]}, - #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++ + #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_s)]}, + #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_ADHOC_s)]}, + #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_VCARD_s)]}] ++ - lists:map(fun(Feature) -> -- #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++Feature)]} +- #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_s++"#"++Feature)]} + lists:map(fun -+ ("rsm") -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_RSM_s)]}; -+ (Feature) -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++Feature)]} ++ ("rsm") -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_RSM_s)]}; ++ (Feature) -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR(<<"var">>, ?NS_PUBSUB_s++"#"++Feature)]} end, features(Host, Node))}; ?NS_ADHOC_b -> command_disco_info(Host, Node, From); @@ -400,7 +400,7 @@ CommandItems = [ #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', @@ -1173,19 +986,20 @@ - ?XMLATTR('name', "Get Pending") + ?XMLATTR(<<"name">>, "Get Pending") ]}], {result, CommandItems}; -iq_disco_items(_Host, ?NS_PUBSUB_GET_PENDING, _From) -> @@ -427,7 +427,7 @@ fun(#pubsub_node{id = {_, SubNode}, options = SubOptions}) -> @@ -1203,7 +1017,7 @@ {result, Name} = node_call(Type, get_item_name, [Host, Node, RN]), - #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host), ?XMLATTR('name', Name)]} + #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR(<<"jid">>, Host), ?XMLATTR('name', Name)]} end, NodeItems), - {result, Nodes ++ Items} + {result, Nodes ++ Items ++ jlib:rsm_encode(RsmOut)} @@ -680,8 +680,8 @@ - {result, XdataEl} = pubsub_subscription:get_options_xform(Lang, Options), + {result, XdataEl} = pubsub_subscription_odbc:get_options_xform(Lang, Options), OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options', - attrs = [ ?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)), - ?XMLATTR('subid', SubId) | nodeAttr(Node)], + attrs = [ ?XMLATTR(<<"jid">>, exmpp_jid:to_binary(Subscriber)), + ?XMLATTR(<<"subid">>, SubId) | nodeAttr(Node)], @@ -2623,7 +2443,7 @@ end. @@ -701,7 +701,7 @@ {error, extended_error('not-acceptable', "invalid-subid")}; {result, _} -> @@ -2827,8 +2647,8 @@ - ?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]}, + ?XMLATTR(<<"subsription">>, subscription_to_string(Sub)) | nodeAttr(Node)]}]}]}, ejabberd_router:route(service_jid(Host), JID, Stanza) end, - Action = fun(#pubsub_node{owners = Owners, type = Type, idx = Nidx}) -> diff --git a/src/mod_pubsub/pubsub_subscription.erl b/src/mod_pubsub/pubsub_subscription.erl index be33aa0ea..348c67766 100644 --- a/src/mod_pubsub/pubsub_subscription.erl +++ b/src/mod_pubsub/pubsub_subscription.erl @@ -170,10 +170,10 @@ get_options_xform(Lang, Options) -> Keys = [deliver, digest, digest_frequency, expire, include_body, show_values, subscription_type, subscription_depth], XFields = [get_option_xfield(Lang, Key, Options) || Key <- Keys], - {result, #xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR('type', <<"form">>)], children = + {result, #xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [?XMLATTR(<<"type">>, <<"form">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'field', - attrs = [?XMLATTR('var', <<"FORM_TYPE">>), ?XMLATTR('type', <<"hidden">>)], + attrs = [?XMLATTR(<<"var">>, <<"FORM_TYPE">>), ?XMLATTR(<<"type">>, <<"hidden">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [?XMLCDATA(?NS_PUBSUB_SUBSCRIBE_OPTIONS_s)]}]}] ++ XFields}}. @@ -349,7 +349,7 @@ get_option_xfield(Lang, Key, Options) -> end, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', - attrs = [?XMLATTR('var', Var), ?XMLATTR('type', Type), ?XMLATTR('label', translate:translate(Lang, Label))], + attrs = [?XMLATTR(<<"var">>, Var), ?XMLATTR(<<"type">>, Type), ?XMLATTR(<<"label">>, translate:translate(Lang, Label))], children = OptEls ++ Vals}. %% TODO : check input type data @@ -362,7 +362,7 @@ type_and_options(Type, _Lang) -> tr_xfield_options({Value, Label}, Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'option', - attrs = [?XMLATTR('label', translate:translate(Lang, Label))], + attrs = [?XMLATTR(<<"label">>, translate:translate(Lang, Label))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [?XMLCDATA(Value)]}]}. diff --git a/src/mod_pubsub/pubsub_subscription_odbc.erl b/src/mod_pubsub/pubsub_subscription_odbc.erl index b03b10cd2..c767009e3 100644 --- a/src/mod_pubsub/pubsub_subscription_odbc.erl +++ b/src/mod_pubsub/pubsub_subscription_odbc.erl @@ -125,7 +125,7 @@ get_options_xform(Lang, Options) -> {result, #xmlel{ns = ?NS_DATA_FORMS, name = 'x', children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'field', - attrs = [?XMLATTR('var', <<"FORM_TYPE">>), ?XMLATTR('type', <<"hidden">>)], + attrs = [?XMLATTR(<<"var">>, <<"FORM_TYPE">>), ?XMLATTR(<<"type">>, <<"hidden">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [?XMLCDATA(?NS_PUBSUB_SUBSCRIBE_OPTIONS_s)]}]}] ++ XFields}}. @@ -226,7 +226,7 @@ get_option_xfield(Lang, Key, Options) -> end, #xmlel{ns = ?NS_DATA_FORMS, name = 'field', - attrs = [?XMLATTR('var', Var), ?XMLATTR('type', Type), ?XMLATTR('label', translate:translate(Lang, Label))], + attrs = [?XMLATTR(<<"var">>, Var), ?XMLATTR(<<"type">>, Type), ?XMLATTR('label', translate:translate(Lang, Label))], children = OptEls ++ Vals}. type_and_options({Type, Options}, Lang) -> @@ -237,7 +237,7 @@ type_and_options(Type, _Lang) -> tr_xfield_options({Value, Label}, Lang) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'option', - attrs = [?XMLATTR('label', translate:translate(Lang, Label))], + attrs = [?XMLATTR(<<"label">>, translate:translate(Lang, Label))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [?XMLCDATA(Value)]}]}. diff --git a/src/mod_register.erl b/src/mod_register.erl index d8e738b8a..99e6b623e 100644 --- a/src/mod_register.erl +++ b/src/mod_register.erl @@ -221,16 +221,16 @@ process_iq(From, To, "Choose a username and password " "to register with this server"))}]}, UField = #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"username">>), - ?XMLATTR('type', <<"text-single">>), - ?XMLATTR('label', translate:translate(Lang, "User"))], + [?XMLATTR(<<"var">>, <<"username">>), + ?XMLATTR(<<"type">>, <<"text-single">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, "User"))], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'required'}]}, PField = #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', <<"password">>), - ?XMLATTR('type', <<"text-private">>), - ?XMLATTR('label', translate:translate(Lang, "Password"))], + [?XMLATTR(<<"var">>, <<"password">>), + ?XMLATTR(<<"type">>, <<"text-private">>), + ?XMLATTR(<<"label">>, translate:translate(Lang, "Password"))], children = [ #xmlel{ns = ?NS_DATA_FORMS, name = 'required'} ] diff --git a/src/mod_roster.erl b/src/mod_roster.erl index 1a7756113..feb9a2f2e 100644 --- a/src/mod_roster.erl +++ b/src/mod_roster.erl @@ -291,7 +291,7 @@ process_iq_get(From, To, IQ_Rec) -> US = {_, LServer} = {exmpp_jid:prep_node(From), exmpp_jid:prep_domain(From)}, try {ItemsToSend, VersionToSend} = - case {exmpp_xml:get_attribute_as_list(exmpp_iq:get_request(IQ_Rec), ver, not_found), + case {exmpp_xml:get_attribute_as_list(exmpp_iq:get_request(IQ_Rec), <<"ver">>, not_found), roster_versioning_enabled(LServer), roster_version_on_db(LServer)} of {not_found, _ , _} -> @@ -332,7 +332,7 @@ process_iq_get(From, To, IQ_Rec) -> {Items, false} -> exmpp_iq:result(IQ_Rec, exmpp_xml:element(?NS_ROSTER, 'query', [] , Items)); {Items, Version} -> - exmpp_iq:result(IQ_Rec, exmpp_xml:element(?NS_ROSTER, 'query', [?XMLATTR('ver', Version)], Items)) + exmpp_iq:result(IQ_Rec, exmpp_xml:element(?NS_ROSTER, 'query', [?XMLATTR(<<"ver">>, Version)], Items)) end catch _:_ -> @@ -408,22 +408,22 @@ convert_to_string(A) when is_list(A) -> A. item_to_xml(Item) -> {U, S, R} = Item#roster.jid, Attrs1 = exmpp_xml:set_attribute_in_list([], - 'jid', exmpp_jid:to_binary(U, S, R)), + <<"jid">>, exmpp_jid:to_binary(U, S, R)), Attrs2 = case Item#roster.name of <<>> -> Attrs1; Name -> - exmpp_xml:set_attribute_in_list(Attrs1, 'name', Name) + exmpp_xml:set_attribute_in_list(Attrs1, <<"name">>, Name) end, Attrs3 = exmpp_xml:set_attribute_in_list(Attrs2, - 'subscription', Item#roster.subscription), + <<"subscription">>, Item#roster.subscription), Attrs4 = case ask_to_pending(Item#roster.ask) of out -> exmpp_xml:set_attribute_in_list(Attrs3, - 'ask', <<"subscribe">>); + <<"ask">>, <<"subscribe">>); both -> exmpp_xml:set_attribute_in_list(Attrs3, - 'ask', <<"subscribe">>); + <<"ask">>, <<"subscribe">>); _ -> Attrs3 end, @@ -466,7 +466,7 @@ try_process_iq_set(From, To, IQ) -> process_item_set(From, To, #xmlel{} = El) -> try - JID1 = exmpp_jid:parse(exmpp_xml:get_attribute_as_binary(El, 'jid', <<>>)), + JID1 = exmpp_jid:parse(exmpp_xml:get_attribute_as_binary(El, <<"jid">>, <<>>)), User = exmpp_jid:node(From), LUser = exmpp_jid:prep_node(From), LServer = exmpp_jid:prep_domain(From), @@ -577,9 +577,9 @@ process_item_set(_From, _To, _) -> process_item_attrs(Item, [#xmlattr{name = Attr, value = Val} | Attrs]) -> case Attr of - 'name' -> + <<"name">> -> process_item_attrs(Item#roster{name = Val}, Attrs); - 'subscription' -> + <<"subscription">> -> case Val of <<"remove">> -> process_item_attrs(Item#roster{subscription = remove}, @@ -587,7 +587,7 @@ process_item_attrs(Item, [#xmlattr{name = Attr, value = Val} | Attrs]) -> _ -> process_item_attrs(Item, Attrs) end; - 'ask' -> + <<"ask">> -> process_item_attrs(Item, Attrs); _ -> process_item_attrs(Item, Attrs) @@ -631,10 +631,10 @@ push_item(User, Server, From, Item) ejabberd_sm:route(exmpp_jid:make(), exmpp_jid:make(User, Server), #xmlel{name = 'broadcast', ns = roster_item, attrs = - [exmpp_xml:attribute(u, U), - exmpp_xml:attribute(s, S), - exmpp_xml:attribute(r, R), - exmpp_xml:attribute(subs, Item#roster.subscription)]}), + [?XMLATTR(<<"u">>, U), + ?XMLATTR(<<"s">>, S), + ?XMLATTR(<<"r">>, R), + ?XMLATTR(<<"subs">>, Item#roster.subscription)]}), case roster_versioning_enabled(Server) of true -> @@ -673,7 +673,7 @@ push_item_version(Server, User, From, Item, RosterVersion) -> end, ejabberd_sm:get_user_resources(User, Server)). push_item_version(User, Server, Resource, From, Item, RosterVersion) -> - Request = #xmlel{ns = ?NS_ROSTER, name = 'query', attrs = [?XMLATTR('ver', RosterVersion)], + Request = #xmlel{ns = ?NS_ROSTER, name = 'query', attrs = [?XMLATTR(<<"ver">>, RosterVersion)], children = [mod_roster:item_to_xml(Item)]}, ResIQ = exmpp_iq:set(?NS_JABBER_CLIENT, Request, "push" ++ randoms:get_string()), @@ -1053,7 +1053,7 @@ set_items(User, Server, #xmlel{children = Els}) process_item_set_t(LUser, LServer, #xmlel{} = El) -> try - JID1 = exmpp_jid:parse(exmpp_xml:get_attribute_as_list(El, 'jid', <<>>)), + JID1 = exmpp_jid:parse(exmpp_xml:get_attribute_as_list(El, <<"jid">>, <<>>)), JID = jlib:short_jid(JID1), LJID = jlib:short_prepd_jid(JID1), Item = #roster{usj = {LUser, LServer, LJID}, @@ -1097,9 +1097,9 @@ process_item_set_t(_LUser, _LServer, _) -> process_item_attrs_ws(Item, [#xmlattr{name = Attr, value = Val} | Attrs]) -> case Attr of - 'name' -> + <<"name">> -> process_item_attrs_ws(Item#roster{name = Val}, Attrs); - 'subscription' -> + <<"subscription">> -> case Val of <<"remove">> -> process_item_attrs_ws(Item#roster{subscription = remove}, @@ -1119,7 +1119,7 @@ process_item_attrs_ws(Item, [#xmlattr{name = Attr, value = Val} | Attrs]) -> _ -> process_item_attrs_ws(Item, Attrs) end; - 'ask' -> + <<"ask">> -> process_item_attrs_ws(Item, Attrs); _ -> process_item_attrs_ws(Item, Attrs) @@ -1363,16 +1363,16 @@ user_roster(User, Server, Query, Lang) -> TDJID = build_contact_jid_td(R#roster.jid), ?XE("tr", [TDJID, - ?XAC("td", [?XMLATTR('class', <<"valign">>)], + ?XAC("td", [?XMLATTR(<<"class">>, <<"valign">>)], R#roster.name), - ?XAC("td", [?XMLATTR('class', <<"valign">>)], + ?XAC("td", [?XMLATTR(<<"class">>, <<"valign">>)], atom_to_list(R#roster.subscription)), - ?XAC("td", [?XMLATTR('class', <<"valign">>)], + ?XAC("td", [?XMLATTR(<<"class">>, <<"valign">>)], atom_to_list(Pending)), - ?XAE("td", [?XMLATTR('class', <<"valign">>)], Groups), + ?XAE("td", [?XMLATTR(<<"class">>, <<"valign">>)], Groups), if Pending == in -> - ?XAE("td", [?XMLATTR('class', <<"valign">>)], + ?XAE("td", [?XMLATTR(<<"class">>, <<"valign">>)], [?INPUTT("submit", "validate" ++ ejabberd_web_admin:term_to_id(R#roster.jid), @@ -1380,7 +1380,7 @@ user_roster(User, Server, Query, Lang) -> true -> ?X("td") end, - ?XAE("td", [?XMLATTR('class', <<"valign">>)], + ?XAE("td", [?XMLATTR(<<"class">>, <<"valign">>)], [?INPUTT("submit", "remove" ++ ejabberd_web_admin:term_to_id(R#roster.jid), @@ -1393,7 +1393,7 @@ user_roster(User, Server, Query, Lang) -> error -> [?XREST("Bad format")]; nothing -> [] end ++ - [?XAE("form", [?XMLATTR('action', <<"">>), ?XMLATTR('method', <<"post">>)], + [?XAE("form", [?XMLATTR(<<"action">>, <<"">>), ?XMLATTR(<<"method">>, <<"post">>)], FItems ++ [?P, ?INPUT("text", "newjid", ""), ?C(" "), @@ -1403,7 +1403,7 @@ user_roster(User, Server, Query, Lang) -> _ -> [?XC("h1", ?T("Roster of ") ++ us_to_list({User, Server}))] ++ [?CT("Bad format"), ?P] ++ - [?XAE("form", [?XMLATTR('action', <<"">>), ?XMLATTR('method', <<"post">>)], + [?XAE("form", [?XMLATTR(<<"action">>, <<"">>), ?XMLATTR(<<"method">>, <<"post">>)], [?P, ?INPUT("text", "newjid", ""), ?C(" "), ?INPUTT("submit", "addjid", "Add Jabber ID") @@ -1429,9 +1429,9 @@ build_contact_jid_td({U, S, R}) -> end, case JIDURI of [] -> - ?XAC('td', [?XMLATTR('class', <<"valign">>)], exmpp_jid:to_list(ContactJID)); + ?XAC('td', [?XMLATTR(<<"class">>, <<"valign">>)], exmpp_jid:to_list(ContactJID)); URI when is_list(URI) -> - ?XAE('td', [?XMLATTR('class', <<"valign">>)], [?AC(JIDURI, exmpp_jid:to_list(ContactJID))]) + ?XAE('td', [?XMLATTR(<<"class">>, <<"valign">>)], [?AC(JIDURI, exmpp_jid:to_list(ContactJID))]) end. %% @spec (User, Server, Items, Query) -> ok | nothing | error @@ -1509,9 +1509,9 @@ user_roster_item_parse_query(User, Server, Items, Query) -> {U, S, R} = JID, UJID = exmpp_jid:make(User, Server), Attrs1 = exmpp_xml:set_attribute_in_list([], - 'jid', exmpp_jid:to_list(U, S, R)), + <<"jid">>, exmpp_jid:to_list(U, S, R)), Attrs2 = exmpp_xml:set_attribute_in_list(Attrs1, - 'subscription', "remove"), + <<"subscription">>, "remove"), Item = #xmlel{ns = ?NS_ROSTER, name = 'item', attrs = Attrs2}, Request = #xmlel{ diff --git a/src/mod_roster_odbc.erl b/src/mod_roster_odbc.erl index 14de60a44..5181d106e 100644 --- a/src/mod_roster_odbc.erl +++ b/src/mod_roster_odbc.erl @@ -178,7 +178,7 @@ process_iq_get(From, To, IQ_Rec) -> US = {LUser, LServer} = {exmpp_jid:prep_node(From), exmpp_jid:prep_domain(From)}, try {ItemsToSend, VersionToSend} = - case {exmpp_xml:get_attribute_as_list(exmpp_iq:get_request(IQ_Rec), ver, not_found), + case {exmpp_xml:get_attribute_as_list(exmpp_iq:get_request(IQ_Rec), <<"ver">>, not_found), roster_versioning_enabled(LServer), roster_version_on_db(LServer)} of {not_found, _ , _} -> @@ -222,7 +222,7 @@ process_iq_get(From, To, IQ_Rec) -> {Items, false} -> exmpp_iq:result(IQ_Rec, exmpp_xml:element(?NS_ROSTER, 'query', [] , Items)); {Items, Version} -> - exmpp_iq:result(IQ_Rec, exmpp_xml:element(?NS_ROSTER, 'query', [?XMLATTR('ver', Version)], Items)) + exmpp_iq:result(IQ_Rec, exmpp_xml:element(?NS_ROSTER, 'query', [?XMLATTR(<<"ver">>, Version)], Items)) end catch _:_ -> @@ -278,22 +278,22 @@ get_roster(LUser, LServer) when is_binary(LUser), is_binary(LServer)-> item_to_xml(Item) -> {U, S, R} = Item#roster.jid, Attrs1 = exmpp_xml:set_attribute_in_list([], - 'jid', exmpp_jid:to_binary(U, S, R)), + <<"jid">>, exmpp_jid:to_binary(U, S, R)), Attrs2 = case Item#roster.name of <<>> -> Attrs1; Name -> - exmpp_xml:set_attribute_in_list(Attrs1, 'name', Name) + exmpp_xml:set_attribute_in_list(Attrs1, <<"name">>, Name) end, Attrs3 = exmpp_xml:set_attribute_in_list(Attrs2, - 'subscription', Item#roster.subscription), + <<"subscription">>, Item#roster.subscription), Attrs = case ask_to_pending(Item#roster.ask) of out -> exmpp_xml:set_attribute_in_list(Attrs3, - 'ask', <<"subscribe">>); + <<"ask">>, <<"subscribe">>); both -> exmpp_xml:set_attribute_in_list(Attrs3, - 'ask', <<"subscribe">>); + <<"ask">>, <<"subscribe">>); _ -> Attrs3 end, @@ -315,7 +315,7 @@ process_iq_set(From, To, #iq{payload = Request} = IQ_Rec) -> process_item_set(From, To, #xmlel{} = El) -> try - JID1 = exmpp_jid:parse(exmpp_xml:get_attribute_as_binary(El, 'jid', <<>>)), + JID1 = exmpp_jid:parse(exmpp_xml:get_attribute_as_binary(El, <<"jid">>, <<>>)), User = exmpp_jid:prep_node(From), Server = exmpp_jid:prep_domain(From), LServer = binary_to_list(Server), @@ -416,9 +416,9 @@ process_item_set(_From, _To, _) -> process_item_attrs(Item, [#xmlattr{name = Attr, value = Val} | Attrs]) -> case Attr of - 'name' -> + <<"name">> -> process_item_attrs(Item#roster{name = Val}, Attrs); - 'subscription' -> + <<"subscription">> -> case Val of <<"remove">> -> process_item_attrs(Item#roster{subscription = remove}, @@ -426,7 +426,7 @@ process_item_attrs(Item, [#xmlattr{name = Attr, value = Val} | Attrs]) -> _ -> process_item_attrs(Item, Attrs) end; - 'ask' -> + <<"ask">> -> process_item_attrs(Item, Attrs); _ -> process_item_attrs(Item, Attrs) @@ -454,10 +454,10 @@ push_item(User, Server, From, Item) when is_binary(User), is_binary(Server) -> ejabberd_sm:route(exmpp_jid:make(), exmpp_jid:make(User, Server), #xmlel{name = 'broadcast', ns = roster_item, attrs = - [exmpp_xml:attribute(u, U), - exmpp_xml:attribute(s, S), - exmpp_xml:attribute(r, R), - exmpp_xml:attribute(subs, Item#roster.subscription)]}), + [?XMLATTR(<<"u">>, U), + ?XMLATTR(<<"s">>, S), + ?XMLATTR(<<"r">>, R), + ?XMLATTR(<<"subs">>, Item#roster.subscription)]}), case roster_versioning_enabled(Server) of true -> push_item_version(Server, User, From, Item, roster_version(Server, User)); @@ -487,7 +487,7 @@ push_item_version(Server, User, From, Item, RosterVersion) -> end, ejabberd_sm:get_user_resources(User, Server)). push_item_version(User, Server, Resource, From, Item, RosterVersion) -> - Request = #xmlel{ns = ?NS_ROSTER, name = 'query', attrs = [?XMLATTR('ver', RosterVersion)], + Request = #xmlel{ns = ?NS_ROSTER, name = 'query', attrs = [?XMLATTR(<<"ver">>, RosterVersion)], children = [mod_roster:item_to_xml(Item)]}, ResIQ = exmpp_iq:set(?NS_JABBER_CLIENT, Request, "push" ++ randoms:get_string()), @@ -827,7 +827,7 @@ set_items(User, Server, #xmlel{children = Els}) when is_binary(User), is_binary( process_item_set_t(LUser, LServer, #xmlel{} = El) -> try - JID1 = exmpp_jid:parse(exmpp_xml:get_attribute_as_binary(El, 'jid', <<>>)), + JID1 = exmpp_jid:parse(exmpp_xml:get_attribute_as_binary(El, <<"jid">>, <<>>)), {U0, S0, R0} = LJID = jlib:short_prepd_jid(JID1), Username = ejabberd_odbc:escape(LUser), SJID = ejabberd_odbc:escape(exmpp_jid:to_binary(U0, S0, R0)), @@ -853,9 +853,9 @@ process_item_set_t(_LUser, _LServer, _) -> process_item_attrs_ws(Item, [#xmlattr{name = Attr, value = Val} | Attrs]) -> case Attr of - 'name' -> + <<"name">> -> process_item_attrs_ws(Item#roster{name = Val}, Attrs); - 'subscription' -> + <<"subscription">> -> case Val of <<"remove">> -> process_item_attrs_ws(Item#roster{subscription = remove}, @@ -1103,16 +1103,16 @@ user_roster(User, Server, Query, Lang) -> TDJID = build_contact_jid_td(R#roster.jid), ?XE("tr", [TDJID, - ?XAC("td", [?XMLATTR('class', <<"valign">>)], + ?XAC("td", [?XMLATTR(<<"class">>, <<"valign">>)], binary_to_list(R#roster.name)), - ?XAC("td", [?XMLATTR('class', <<"valign">>)], + ?XAC("td", [?XMLATTR(<<"class">>, <<"valign">>)], atom_to_list(R#roster.subscription)), - ?XAC("td", [?XMLATTR('class', <<"valign">>)], + ?XAC("td", [?XMLATTR(<<"class">>, <<"valign">>)], atom_to_list(Pending)), - ?XAE("td", [?XMLATTR('class', <<"valign">>)], Groups), + ?XAE("td", [?XMLATTR(<<"class">>, <<"valign">>)], Groups), if Pending == in -> - ?XAE("td", [?XMLATTR('class', <<"valign">>)], + ?XAE("td", [?XMLATTR(<<"class">>, <<"valign">>)], [?INPUTT("submit", "validate" ++ ejabberd_web_admin:term_to_id(R#roster.jid), @@ -1120,7 +1120,7 @@ user_roster(User, Server, Query, Lang) -> true -> ?X("td") end, - ?XAE("td", [?XMLATTR('class', <<"valign">>)], + ?XAE("td", [?XMLATTR(<<"class">>, <<"valign">>)], [?INPUTT("submit", "remove" ++ ejabberd_web_admin:term_to_id(R#roster.jid), @@ -1133,7 +1133,7 @@ user_roster(User, Server, Query, Lang) -> error -> [?XREST("Bad format")]; nothing -> [] end ++ - [?XAE("form", [?XMLATTR('action', <<"">>), ?XMLATTR('method', <<"post">>)], + [?XAE("form", [?XMLATTR(<<"action">>, <<"">>), ?XMLATTR(<<"method">>, <<"post">>)], FItems ++ [?P, ?INPUT("text", "newjid", ""), ?C(" "), @@ -1143,7 +1143,7 @@ user_roster(User, Server, Query, Lang) -> _ -> [?XC("h1", ?T("Roster of ") ++ us_to_list({User, Server}))] ++ [?CT("Bad format"), ?P] ++ - [?XAE("form", [?XMLATTR('action', <<"">>), ?XMLATTR('method', <<"post">>)], + [?XAE("form", [?XMLATTR(<<"action">>, <<"">>), ?XMLATTR(<<"method">>, <<"post">>)], [?P, ?INPUT("text", "newjid", ""), ?C(" "), ?INPUTT("submit", "addjid", "Add Jabber ID") @@ -1165,9 +1165,9 @@ build_contact_jid_td({U, S, R}) -> end, case JIDURI of [] -> - ?XAC('td', [?XMLATTR('class', <<"valign">>)], exmpp_jid:to_list(ContactJID)); + ?XAC('td', [?XMLATTR(<<"class">>, <<"valign">>)], exmpp_jid:to_list(ContactJID)); URI when is_list(URI) -> - ?XAE('td', [?XMLATTR('class', <<"valign">>)], [?AC(JIDURI, exmpp_jid:to_list(ContactJID))]) + ?XAE('td', [?XMLATTR(<<"class">>, <<"valign">>)], [?AC(JIDURI, exmpp_jid:to_list(ContactJID))]) end. user_roster_parse_query(User, Server, Items, Query) -> @@ -1228,9 +1228,9 @@ user_roster_item_parse_query(User, Server, Items, Query) -> {value, _} -> UJID = exmpp_jid:make(User, Server), Attrs1 = exmpp_xml:set_attribute_in_list([], - 'jid', exmpp_jid:to_list(JID)), + <<"jid">>, exmpp_jid:to_list(JID)), Attrs2 = exmpp_xml:set_attribute_in_list(Attrs1, - 'subscription', "remove"), + <<"subscription">>, "remove"), Item = #xmlel{ns = ?NS_ROSTER, name = 'item', attrs = Attrs2}, Request = #xmlel{ diff --git a/src/mod_shared_roster.erl b/src/mod_shared_roster.erl index 0f2a91670..018e71085 100644 --- a/src/mod_shared_roster.erl +++ b/src/mod_shared_roster.erl @@ -740,10 +740,10 @@ push_item(User, Server, From, Item) -> {U, S, R} = Item#roster.jid, ejabberd_sm:route(From, exmpp_jid:make(User, Server), #xmlel{name = 'broadcast', ns = roster_item, attrs = - [exmpp_xml:attribute(u, U), - exmpp_xml:attribute(s, S), - exmpp_xml:attribute(r, R), - exmpp_xml:attribute(subs, Item#roster.subscription)]}), + [?XMLATTR(<<"u">>, U), + ?XMLATTR(<<"s">>, S), + ?XMLATTR(<<"r">>, R), + ?XMLATTR(<<"subs">>, Item#roster.subscription)]}), Request = #xmlel{ns = ?NS_ROSTER, name = 'query', children = [mod_roster:item_to_xml(Item)]}, Stanza = exmpp_iq:set(?NS_JABBER_CLIENT, Request, @@ -817,7 +817,7 @@ list_shared_roster_groups(Host, Query, Lang) -> error -> [?XREST("Bad format")]; nothing -> [] end ++ - [?XAE("form", [?XMLATTR('action', <<"">>), ?XMLATTR('method', <<"post">>)], + [?XAE("form", [?XMLATTR(<<"action">>, <<"">>), ?XMLATTR(<<"method">>, <<"post">>)], [FGroups, ?BR, ?INPUTT("submit", "delete", "Delete Selected") @@ -879,7 +879,7 @@ shared_roster_group(Host, Group, Query, Lang) -> FDisplayedGroups = [[DG, $\n] || DG <- DisplayedGroups], DescNL = length(re:split(Description, "\n", [{return, list}])), FGroup = - ?XAE("table", [?XMLATTR('class', <<"withtextareas">>)], + ?XAE("table", [?XMLATTR(<<"class">>, <<"withtextareas">>)], [?XE("tbody", [?XE("tr", [?XCT("td", "Group ID:"), @@ -923,7 +923,7 @@ shared_roster_group(Host, Group, Query, Lang) -> error -> [?XREST("Bad format")]; nothing -> [] end ++ - [?XAE("form", [?XMLATTR('action', <<"">>), ?XMLATTR('method', <<"post">>)], + [?XAE("form", [?XMLATTR(<<"action">>, <<"">>), ?XMLATTR(<<"method">>, <<"post">>)], [FGroup, ?BR, ?INPUTT("submit", "submit", "Submit") diff --git a/src/mod_stats.erl b/src/mod_stats.erl index a914e752e..ef381f503 100644 --- a/src/mod_stats.erl +++ b/src/mod_stats.erl @@ -46,7 +46,7 @@ stop(Host) -> process_local_iq(_From, To, #iq{type = get, ns = XMLNS, payload = SubEl} = IQ_Rec) -> - Node = string:tokens(exmpp_xml:get_attribute_as_list(SubEl, 'node', ""), "/"), + Node = string:tokens(exmpp_xml:get_attribute_as_list(SubEl, <<"node">>, ""), "/"), Names = get_names(exmpp_xml:get_child_elements(SubEl), []), case get_local_stats(exmpp_jid:domain(To), Node, Names) of @@ -63,7 +63,7 @@ process_local_iq(_From, _To, #iq{type = set} = IQ_Rec) -> get_names([], Res) -> Res; get_names([#xmlel{name = "stat", attrs = Attrs} | Els], Res) -> - Name = exmpp_xml:get_attribute_from_list_as_binary(Attrs, 'name', <<>>), + Name = exmpp_xml:get_attribute_from_list_as_binary(Attrs, <<"name">>, <<>>), case Name of <<>> -> get_names(Els, Res); @@ -74,7 +74,7 @@ get_names([_ | Els], Res) -> get_names(Els, Res). --define(STAT(Name), #xmlel{ns = ?NS_STATS_s, name = 'stat', attrs = [?XMLATTR('name', Name)]}). +-define(STAT(Name), #xmlel{ns = ?NS_STATS_s, name = 'stat', attrs = [?XMLATTR(<<"name">>, Name)]}). get_local_stats(_Server, [], []) -> {result, @@ -116,16 +116,16 @@ get_local_stats(_Server, _, _) -> -define(STATVAL(Val, Unit), #xmlel{ns = ?NS_STATS_s, name = 'stat', attrs = - [?XMLATTR('name', Name), - ?XMLATTR('units', Unit), - ?XMLATTR('value', Val) + [?XMLATTR(<<"name">>, Name), + ?XMLATTR(<<"units">>, Unit), + ?XMLATTR(<<"value">>, Val) ]}). -define(STATERR(Code, Desc), #xmlel{ns = ?NS_STATS_s, name = 'stat', attrs= - [?XMLATTR('name', Name)], children = + [?XMLATTR(<<"name">>, Name)], children = [#xmlel{ns = ?NS_STATS_s, name = 'error', attrs = - [?XMLATTR('code', Code)], children = + [?XMLATTR(<<"code">>, Code)], children = [#xmlcdata{cdata = Desc}]}]}). diff --git a/src/mod_vcard.erl b/src/mod_vcard.erl index f5889ad77..23ab65290 100644 --- a/src/mod_vcard.erl +++ b/src/mod_vcard.erl @@ -339,16 +339,16 @@ set_vcard(User, LServer, LServerB, VCARD) -> -define(TLFIELD(Type, Label, Var), #xmlel{ns = ?NS_VCARD, name = 'field', attrs = [ - ?XMLATTR('type', Type), - ?XMLATTR('label', translate:translate(Lang, Label)), - ?XMLATTR('var', Var)]}). + ?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"label">>, translate:translate(Lang, Label)), + ?XMLATTR(<<"var">>, Var)]}). -define(FORM(JID), [#xmlel{ns = ?NS_SEARCH, name = 'instructions', children = [#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "You need an x:data capable client to search"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = - [?XMLATTR('type', <<"form">>)], children = + [?XMLATTR(<<"type">>, <<"form">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Search users in ") ++ exmpp_jid:to_list(JID))}]}, #xmlel{ns = ?NS_SEARCH, name = 'instructions', children = @@ -410,7 +410,7 @@ do_route(ServerHost, From, To, Packet) -> children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', - attrs = [?XMLATTR('type', + attrs = [?XMLATTR(<<"type">>, <<"result">>)], children = search_result(Lang, To, ServerHost, XData)}]}, @@ -439,19 +439,19 @@ do_route(ServerHost, From, To, Packet) -> children = Info ++ [ #xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = [ - ?XMLATTR('category', <<"directory">>), - ?XMLATTR('type', <<"user">>), - ?XMLATTR('name', translate:translate(Lang, + ?XMLATTR(<<"category">>, <<"directory">>), + ?XMLATTR(<<"type">>, <<"user">>), + ?XMLATTR(<<"name">>, translate:translate(Lang, "vCard User Search"))]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [ - ?XMLATTR('var', ?NS_DISCO_INFO_s)]}, + ?XMLATTR(<<"var">>, ?NS_DISCO_INFO_s)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [ - ?XMLATTR('var', ?NS_SEARCH_s)]}, + ?XMLATTR(<<"var">>, ?NS_SEARCH_s)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [ - ?XMLATTR('var', ?NS_VCARD_s)]} + ?XMLATTR(<<"var">>, ?NS_VCARD_s)]} ]}, ResIQ = exmpp_iq:result(Packet, Result), ejabberd_router:route(To, @@ -528,7 +528,7 @@ search_result(Lang, JID, ServerHost, Data) -> -define(FIELD(Var, Val), #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', Var)], children = + [?XMLATTR(<<"var">>, Var)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = Val}]}]}). @@ -862,9 +862,9 @@ user_vcard(User, Server, Query, Lang) -> {error, M} -> [?XREST(M)]; nothing -> [] end ++ - [?XAE('form', [?XMLATTR('action', <<"">>), ?XMLATTR('method', <<"post">>)], + [?XAE('form', [?XMLATTR(<<"action">>, <<"">>), ?XMLATTR(<<"method">>, <<"post">>)], [?XCT('h3', "vCard Photo:"), - ?XAE('img', [?XMLATTR('src', <<"photo">>), ?XMLATTR('border', <<"1px">>)], []), + ?XAE('img', [?XMLATTR(<<"src">>, <<"photo">>), ?XMLATTR(<<"border">>, <<"1px">>)], []), ?XC('h3', ?T("vCard")++":"), ?XE('pre', [?C(VcardString)]), ?INPUTT("submit", "removevcard", "Remove vCard") diff --git a/src/mod_vcard_ldap.erl b/src/mod_vcard_ldap.erl index 7368194a3..0a29819bc 100644 --- a/src/mod_vcard_ldap.erl +++ b/src/mod_vcard_ldap.erl @@ -387,15 +387,15 @@ ldap_attribute_to_vcard(_, _) -> -define(TLFIELD(Type, Label, Var), #xmlel{ns = ?NS_VCARD, name = 'field', attrs = [ - ?XMLATTR('type', Type), - ?XMLATTR('label', translate:translate(Lang, Label)), - ?XMLATTR('var', Var)]}). + ?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"label">>, translate:translate(Lang, Label)), + ?XMLATTR(<<"var">>, Var)]}). -define(FORM(JID, SearchFields), [#xmlel{ns = ?NS_SEARCH, name = 'instructions', children = [#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "You need an x:data capable client to search"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = - [?XMLATTR('type', <<"form">>)], children = + [?XMLATTR(<<"type">>, <<"form">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Search users in ") ++ exmpp_jid:to_list(JID))}]}, @@ -442,7 +442,7 @@ route(State, From, To, Packet) -> children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'x', - attrs = [?XMLATTR('type', + attrs = [?XMLATTR(<<"type">>, <<"result">>)], children = search_result(Lang, To, State, XData)}]}, ResIQ = exmpp_iq:result(Packet, @@ -471,16 +471,16 @@ route(State, From, To, Packet) -> children = Info ++ [ #xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = [ - ?XMLATTR('category', <<"directory">>), - ?XMLATTR('type', <<"user">>), - ?XMLATTR('name', translate:translate(Lang, + ?XMLATTR(<<"category">>, <<"directory">>), + ?XMLATTR(<<"type">>, <<"user">>), + ?XMLATTR(<<"name">>, translate:translate(Lang, "vCard User Search"))]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [ - ?XMLATTR('var', ?NS_SEARCH_s)]}, + ?XMLATTR(<<"var">>, ?NS_SEARCH_s)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [ - ?XMLATTR('var', ?NS_VCARD_s)]} + ?XMLATTR(<<"var">>, ?NS_VCARD_s)]} ]}, ResIQ = exmpp_iq:result(Packet, Result), ejabberd_router:route(To, @@ -545,7 +545,7 @@ search_result(Lang, JID, State, Data) -> -define(FIELD(Var, Val), #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', Var)], children = + [?XMLATTR(<<"var">>, Var)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = Val}]}]}). diff --git a/src/mod_vcard_odbc.erl b/src/mod_vcard_odbc.erl index 7682646dd..ee0a756bd 100644 --- a/src/mod_vcard_odbc.erl +++ b/src/mod_vcard_odbc.erl @@ -138,7 +138,7 @@ process_sm_iq(_From, To, #iq{type = get} = IQ_Rec) -> {selected, ["vcard"], [{SVCARD}]} -> try exmpp_xml:parse_document(SVCARD, [names_as_atom, {check_elems, xmpp}, - {check_nss,xmpp}, {check_attrs,xmpp}]) of + {check_nss,xmpp} ]) of [VCARD] -> exmpp_iq:result(IQ_Rec, VCARD) catch @@ -253,16 +253,16 @@ set_vcard(User, LServer, VCARD) -> -define(TLFIELD(Type, Label, Var), #xmlel{ns = ?NS_VCARD, name = 'field', attrs = [ - ?XMLATTR('type', Type), - ?XMLATTR('label', translate:translate(Lang, Label)), - ?XMLATTR('var', Var)]}). + ?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"label">>, translate:translate(Lang, Label)), + ?XMLATTR(<<"var">>, Var)]}). -define(FORM(JID), [#xmlel{ns = ?NS_SEARCH, name = 'instructions', children = [#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "You need an x:data capable client to search"))}]}, #xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = - [?XMLATTR('type', <<"form">>)], children = + [?XMLATTR(<<"type">>, <<"form">>)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'title', children = [#xmlcdata{cdata = list_to_binary(translate:translate(Lang, "Search users in ") ++ exmpp_jid:to_list(JID))}]}, #xmlel{ns = ?NS_SEARCH, name = 'instructions', children = @@ -321,7 +321,7 @@ do_route(ServerHost, From, To, Packet) -> #xmlel{ns = ?NS_DATA_FORMS, name = 'x', attrs = [ - ?XMLATTR('type', + ?XMLATTR(<<"type">>, <<"result">>)], children = search_result(Lang, To, ServerHost, XData)}]}, @@ -349,16 +349,16 @@ do_route(ServerHost, From, To, Packet) -> children = Info ++ [ #xmlel{ns = ?NS_DISCO_INFO, name = 'identity', attrs = [ - ?XMLATTR('category', <<"directory">>), - ?XMLATTR('type', <<"user">>), - ?XMLATTR('name', translate:translate(Lang, + ?XMLATTR(<<"category">>, <<"directory">>), + ?XMLATTR(<<"type">>, <<"user">>), + ?XMLATTR(<<"name">>, translate:translate(Lang, "vCard User Search"))]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [ - ?XMLATTR('var', ?NS_SEARCH_s)]}, + ?XMLATTR(<<"var">>, ?NS_SEARCH_s)]}, #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [ - ?XMLATTR('var', ?NS_VCARD_s)]} + ?XMLATTR(<<"var">>, ?NS_VCARD_s)]} ]}, ResIQ = exmpp_iq:result(Packet, Result), ejabberd_router:route(To, @@ -436,7 +436,7 @@ search_result(Lang, JID, ServerHost, Data) -> -define(FIELD(Var, Val), #xmlel{ns = ?NS_DATA_FORMS, name = 'field', attrs = - [?XMLATTR('var', Var)], children = + [?XMLATTR(<<"var">>, Var)], children = [#xmlel{ns = ?NS_DATA_FORMS, name = 'value', children = [#xmlcdata{cdata = Val}]}]}). diff --git a/src/mod_vcard_xupdate.erl b/src/mod_vcard_xupdate.erl index c3d163b13..73c282633 100644 --- a/src/mod_vcard_xupdate.erl +++ b/src/mod_vcard_xupdate.erl @@ -51,7 +51,7 @@ stop(Host) -> update_presence(Packet, User, Host) -> case exmpp_presence:is_presence(Packet) andalso - exmpp_xml:get_attribute_as_binary(Packet, type, undefined) + exmpp_xml:get_attribute_as_binary(Packet, <<"type">>, undefined) == undefined of true -> presence_with_xupdate(Packet, User, Host); diff --git a/src/web/ejabberd_http_bind.erl b/src/web/ejabberd_http_bind.erl index c83b59534..ff4feea8f 100644 --- a/src/web/ejabberd_http_bind.erl +++ b/src/web/ejabberd_http_bind.erl @@ -207,7 +207,7 @@ process_request(Data, IP) -> case catch parse_request(Data, PayloadSize, MaxStanzaSize) of %% No existing session: {ok, {"", Rid, Attrs, Payload}} -> - case exmpp_xml:get_attribute_from_list_as_list(Attrs, "to", "") of + case exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"to">>, "") of "" -> ?DEBUG("Session not created (Improper addressing)", []), {200, ?HEADER, " %% Existing session {ok, {Sid, Rid, Attrs, Payload1}} -> StreamStart = - case exmpp_xml:get_attribute_from_list_as_list(Attrs, ?NS_BOSH, restart, "") of + case exmpp_xml:get_attribute_from_list_as_list(Attrs, ?NS_BOSH, <<"restart">>, "") of "true" -> true; _ -> false end, - Payload2 = case exmpp_xml:get_attribute_from_list_as_list(Attrs, "type", "") of + Payload2 = case exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"type">>, "") of "terminate" -> %% close stream Payload1 ++ [{xmlstreamend, "stream:stream"}]; @@ -264,7 +264,7 @@ process_request(Data, IP) -> handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs, Payload, PayloadSize, IP) -> ?DEBUG("got pid: ~p", [Pid]), - Wait = case string:to_integer(exmpp_xml:get_attribute_from_list_as_list(Attrs, "wait", "")) of + Wait = case string:to_integer(exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"wait">>, "")) of {error, _} -> ?MAX_WAIT; {CWait, _} -> @@ -275,7 +275,7 @@ handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs, CWait end end, - Hold = case string:to_integer(exmpp_xml:get_attribute_from_list_as_list(Attrs, "hold", "")) of + Hold = case string:to_integer(exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"hold">>, "")) of {error, _} -> (?MAX_REQUESTS - 1); {CHold, _} -> @@ -286,7 +286,7 @@ handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs, CHold end end, - Pdelay = case string:to_integer(exmpp_xml:get_attribute_from_list_as_list(Attrs, "process-delay", "")) of + Pdelay = case string:to_integer(exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"process-delay">>, "")) of {error, _} -> ?PROCESS_DELAY_DEFAULT; {CPdelay, _} when @@ -298,11 +298,11 @@ handle_session_start(Pid, XmppDomain, Sid, Rid, Attrs, end, Version = case catch list_to_float( - exmpp_xml:get_attribute_from_list_as_list(Attrs, "ver", "")) of + exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"ver">>, "")) of {'EXIT', _} -> 0.0; V -> V end, - XmppVersion = exmpp_xml:get_attribute_from_list_as_list(Attrs, ?NS_BOSH, version, ""), + XmppVersion = exmpp_xml:get_attribute_from_list_as_list(Attrs, ?NS_BOSH, <<"version">>, ""), ?DEBUG("Create session: ~p", [Sid]), mnesia:async_dirty( fun() -> @@ -638,8 +638,8 @@ process_http_put(#http_put{rid = Rid, attrs = Attrs, payload = Payload, StateName, StateData, RidAllow) -> ?DEBUG("Actually processing request: ~p", [Request]), %% Check if key valid - Key = exmpp_xml:get_attribute_from_list_as_list(Attrs, "key", ""), - NewKey = exmpp_xml:get_attribute_from_list_as_list(Attrs, "newkey", ""), + Key = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"key">>, ""), + NewKey = exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"newkey">>, ""), KeyAllow = case RidAllow of repeat -> @@ -746,7 +746,7 @@ process_http_put(#http_put{rid = Rid, attrs = Attrs, payload = Payload, {To, ""} -> DecNs = [{?NS_XMPP, "stream"}, {?NS_JABBER_CLIENT, none}], - StreamAttrs = [#xmlattr{name = 'to', value = list_to_binary(To)}], + StreamAttrs = [#xmlattr{name = <<"to">>, value = list_to_binary(To)}], StreamEl = #xmlel{name = stream, ns = ?NS_XMPP, declared_ns = DecNs, attrs = StreamAttrs}, gen_fsm:send_event( @@ -755,8 +755,8 @@ process_http_put(#http_put{rid = Rid, attrs = Attrs, payload = Payload, {To, Version} -> DecNs = [{?NS_XMPP, "stream"}, {?NS_JABBER_CLIENT, none}], - StreamAttrs = [#xmlattr{name = 'to', value = list_to_binary(To)}, - #xmlattr{name = 'version', value = list_to_binary(Version)}], + StreamAttrs = [?XMLATTR(<<"to">>, list_to_binary(To)), + ?XMLATTR(<<"version">>, list_to_binary(Version))], StreamEl = #xmlel{name = stream, ns = ?NS_XMPP, declared_ns = DecNs, attrs = StreamAttrs}, gen_fsm:send_event( @@ -869,11 +869,11 @@ handle_http_put_error(Reason, #http_bind{pid=FsmRef, version=Version}) #xmlel{name = 'body', ns = ?NS_HTTP_BIND_s, attrs = [ - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, ns = ?NS_HTTP_BIND_s, value = <<"terminate">> }, - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, ns = ?NS_HTTP_BIND_s, value = <<"item-not-found">> } @@ -885,11 +885,11 @@ handle_http_put_error(Reason, #http_bind{pid=FsmRef, version=Version}) #xmlel{name = 'body', ns = ?NS_HTTP_BIND_s, attrs = [ - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, ns = ?NS_HTTP_BIND_s, value = <<"terminate">> }, - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, ns = ?NS_HTTP_BIND_s, value = <<"item-not-found">> } @@ -901,11 +901,11 @@ handle_http_put_error(Reason, #http_bind{pid=FsmRef, version=Version}) #xmlel{name = 'body', ns = ?NS_HTTP_BIND_s, attrs = [ - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, ns = ?NS_HTTP_BIND_s, value = <<"terminate">> }, - #xmlattr{name = 'type', + #xmlattr{name = <<"type">>, ns = ?NS_HTTP_BIND_s, value = <<"policy-violation">> } @@ -936,7 +936,7 @@ rid_allow(OldRid, NewRid, Attrs, Hold, MaxPause) -> %% We did not miss any packet, we can process it immediately: NewRid == OldRid + 1 -> case catch list_to_integer( - exmpp_xml:get_attribute_from_list_as_list(Attrs, "pause", "")) of + exmpp_xml:get_attribute_from_list_as_list(Attrs, <<"pause">>, "")) of {'EXIT', _} -> {true, 0}; Pause1 when Pause1 =< MaxPause -> @@ -1004,9 +1004,9 @@ prepare_outpacket_response(#http_bind{id=Sid, wait=Wait, Rid, OutPacket, true) -> case OutPacket of [{xmlstreamstart, _, OutAttrs} | Els] -> - AuthID = exmpp_xml:get_attribute_from_list_as_list(OutAttrs, "id", ""), - FromB = exmpp_xml:get_attribute_from_list_as_binary(OutAttrs, "from", ""), - Version = exmpp_xml:get_attribute_from_list_as_list(OutAttrs, "version", ""), + AuthID = exmpp_xml:get_attribute_from_list_as_list(OutAttrs, <<"id">>, ""), + FromB = exmpp_xml:get_attribute_from_list_as_binary(OutAttrs, <<"from">>, <<>>), + Version = exmpp_xml:get_attribute_from_list_as_list(OutAttrs, <<"version">>, ""), OutEls = case Els of [] -> @@ -1045,9 +1045,9 @@ prepare_outpacket_response(#http_bind{id=Sid, wait=Wait, "xmlns='"++?NS_HTTP_BIND_s++"'/>"}; _ -> BOSH_attribs = - [#xmlattr{name = 'authid', value = list_to_binary(AuthID)}, - #xmlattr{name = 'xmlns:stream', value = ?NS_XMPP_b}] ++ - [#xmlattr{name = 'version', ns = ?NS_BOSH_s, value = list_to_binary(Version)}], + [#xmlattr{name = <<"authid">>, value = list_to_binary(AuthID)}, + #xmlattr{name = <<"xmlns:stream">>, value = ?NS_XMPP_b}] ++ + [#xmlattr{name = <<"version">>, ns = ?NS_BOSH_s, value = list_to_binary(Version)}], MaxInactivity = get_max_inactivity(To, ?MAX_INACTIVITY), MaxPause = get_max_pause(To), {200, ?HEADER, @@ -1056,31 +1056,31 @@ prepare_outpacket_response(#http_bind{id=Sid, wait=Wait, ns = ?NS_HTTP_BIND_s, declared_ns = [{?NS_XBOSH_s, ?NS_XBOSH_pfx}], attrs = [ - #xmlattr{name = 'sid', + #xmlattr{name = <<"sid">>, value = list_to_binary(Sid) }, - #xmlattr{name = 'wait', + #xmlattr{name = <<"wait">>, value = list_to_binary(integer_to_list(Wait)) }, - #xmlattr{name = 'requests', + #xmlattr{name = <<"requests">>, value = list_to_binary(integer_to_list(Hold+1)) }, - #xmlattr{name = 'inactivity', + #xmlattr{name = <<"inactivity">>, value = list_to_binary(integer_to_list(trunc(MaxInactivity/1000))) }, - #xmlattr{name = 'maxpause', + #xmlattr{name = <<"maxpause">>, value = list_to_binary(integer_to_list(MaxPause)) }, - #xmlattr{name = 'polling', + #xmlattr{name = <<"polling">>, value = list_to_binary(integer_to_list(trunc(?MIN_POLLING/1000000))) }, - #xmlattr{name = 'ver', + #xmlattr{name = <<"ver">>, value = ?BOSH_VERSION_b }, - #xmlattr{name = 'from', + #xmlattr{name = <<"from">>, value = FromB }, - #xmlattr{name = 'secure', + #xmlattr{name = <<"secure">>, value = <<"true">> } ] ++ BOSH_attribs, @@ -1252,7 +1252,7 @@ parse_request(Data, PayloadSize, MaxStanzaSize) -> {error, bad_request}; true -> %case catch list_to_integer(xml:get_attr_s("rid", Attrs)) of - case catch list_to_integer(exmpp_xml:get_attribute_as_list(Xml, "rid", "")) of + case catch list_to_integer(exmpp_xml:get_attribute_as_list(Xml, <<"rid">>, "")) of {'EXIT', _} -> {error, bad_request}; @@ -1269,7 +1269,7 @@ parse_request(Data, PayloadSize, MaxStanzaSize) -> false end end, Els), - Sid = exmpp_xml:get_attribute_as_list(Xml, "sid", ""), + Sid = exmpp_xml:get_attribute_as_list(Xml, <<"sid">>, ""), if PayloadSize =< MaxStanzaSize -> {ok, {Sid, Rid, Attrs, FixedEls}}; diff --git a/src/web/ejabberd_http_poll.erl b/src/web/ejabberd_http_poll.erl index 1033cbc3b..7aa251c99 100644 --- a/src/web/ejabberd_http_poll.erl +++ b/src/web/ejabberd_http_poll.erl @@ -173,7 +173,7 @@ get_human_html_xmlel() -> Par1 = #xmlel{name = p, children = [#xmlcdata{cdata = <<"An implementation of ">>}, #xmlel{name = a, - attrs = [#xmlattr{name=href, value = <<"http://xmpp.org/extensions/xep-0025.html">>}], + attrs = [#xmlattr{name = <<"href">>, value = <<"http://xmpp.org/extensions/xep-0025.html">>}], children = [#xmlcdata{cdata = <<"Jabber HTTP Polling (XEP-0025)">>}] } ]}, @@ -182,7 +182,7 @@ get_human_html_xmlel() -> "To use HTTP-Poll you need a Jabber/XMPP client that supports it.">>} ]}, #xmlel{name = html, - attrs = [#xmlattr{name = xmlns, value= <<"http://www.w3.org/1999/xhtml">>}], + attrs = [#xmlattr{name = <<"xmlns">>, value= <<"http://www.w3.org/1999/xhtml">>}], children = [#xmlel{name = head, children = [#xmlel{name = title, children = [#xmlcdata{cdata = Heading}]}]}, #xmlel{name = body, children = [H, Par1, Par2]}]}. diff --git a/src/web/ejabberd_web.erl b/src/web/ejabberd_web.erl index 16fe0088e..90c1d8f32 100644 --- a/src/web/ejabberd_web.erl +++ b/src/web/ejabberd_web.erl @@ -48,12 +48,12 @@ make_xhtml(Els) -> make_xhtml(HeadEls, Els) -> #xmlel{ns = ?NS_XHTML, name = 'html', attrs = [ - exmpp_xml:attribute(?NS_XML, 'lang', <<"en">>), - ?XMLATTR('lang', <<"en">>)], children = [ + exmpp_xml:attribute(?NS_XML, <<"lang">>, <<"en">>), + ?XMLATTR(<<"lang">>, <<"en">>)], children = [ #xmlel{ns = ?NS_XHTML, name = 'head', children = [ #xmlel{ns = ?NS_XHTML, name = 'meta', attrs = [ - ?XMLATTR('http-equiv', <<"Content-Type">>), - ?XMLATTR('content', <<"text/html; charset=utf-8">>) + ?XMLATTR(<<"http-equiv">>, <<"Content-Type">>), + ?XMLATTR(<<"content">>, <<"text/html; charset=utf-8">>) ]} | HeadEls ]}, @@ -71,14 +71,14 @@ make_xhtml(HeadEls, Els) -> -define(XAC(Name, Attrs, Text), ?XAE(Name, Attrs, [?C(Text)])). -define(LI(Els), ?XE('li', Els)). --define(A(URL, Els), ?XAE('a', [?XMLATTR('href', URL)], Els)). +-define(A(URL, Els), ?XAE('a', [?XMLATTR(<<"href">>, URL)], Els)). -define(AC(URL, Text), ?A(URL, [?C(Text)])). -define(P, ?X('p')). -define(BR, ?X('br')). -define(INPUT(Type, Name, Value), - ?XA('input', [?XMLATTR('type', Type), - ?XMLATTR('name', Name), - ?XMLATTR('value', Value)])). + ?XA('input', [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"name">>, Name), + ?XMLATTR(<<"value">>, Value)])). error(not_found) -> {404, [], make_xhtml([?XC('h1', "404 Not Found")])}; diff --git a/src/web/ejabberd_web_admin.erl b/src/web/ejabberd_web_admin.erl index d92f54efa..2162a134b 100644 --- a/src/web/ejabberd_web_admin.erl +++ b/src/web/ejabberd_web_admin.erl @@ -43,9 +43,9 @@ -define(INPUTATTRS(Type, Name, Value, Attrs), ?XA("input", Attrs ++ - [?XMLATTR('type', Type), - ?XMLATTR('name', Name), - ?XMLATTR('value', Value)])). + [?XMLATTR(<<"type">>, Type), + ?XMLATTR(<<"name">>, Name), + ?XMLATTR(<<"value">>, Value)])). %%%================================== %%%% get_acl_access @@ -274,50 +274,50 @@ make_xhtml(Els, Host, Node, Lang, JID) -> MenuItems = make_navigation(Host, Node, Lang, JID), {200, [html], #xmlel{ns = ?NS_XHTML, name = 'html', attrs = [ - exmpp_xml:attribute(?NS_XML, 'lang', Lang), - ?XMLATTR('lang', Lang)], children = + exmpp_xml:attribute(?NS_XML, <<"lang">>, Lang), + ?XMLATTR(<<"lang">>, Lang)], children = [#xmlel{ns = ?NS_XHTML, name = 'head', children = [?XCT('title', "ejabberd Web Admin"), #xmlel{ns = ?NS_XHTML, name = 'meta', attrs = [ - ?XMLATTR('http-equiv', <<"Content-Type">>), - ?XMLATTR('content', <<"text/html; charset=utf-8">>)]}, + ?XMLATTR(<<"http-equiv">>, <<"Content-Type">>), + ?XMLATTR(<<"content">>, <<"text/html; charset=utf-8">>)]}, #xmlel{ns = ?NS_XHTML, name = 'script', %% This children is to ensure exmpp puts: children = [?C(".")], attrs = [ - ?XMLATTR('src', Base ++ "additions.js"), - ?XMLATTR('type', <<"text/javascript">>)]}, + ?XMLATTR(<<"src">>, Base ++ "additions.js"), + ?XMLATTR(<<"type">>, <<"text/javascript">>)]}, #xmlel{ns = ?NS_XHTML, name = 'link', attrs = [ - ?XMLATTR('href', Base ++ "favicon.ico"), - ?XMLATTR('type', <<"image/x-icon">>), - ?XMLATTR('rel', <<"shortcut icon">>)]}, + ?XMLATTR(<<"href">>, Base ++ "favicon.ico"), + ?XMLATTR(<<"type">>, <<"image/x-icon">>), + ?XMLATTR(<<"rel">>, <<"shortcut icon">>)]}, #xmlel{ns = ?NS_XHTML, name = 'link', attrs = [ - ?XMLATTR('href', Base ++ "style.css"), - ?XMLATTR('type', <<"text/css">>), - ?XMLATTR('rel', <<"stylesheet">>)]}]}, + ?XMLATTR(<<"href">>, Base ++ "style.css"), + ?XMLATTR(<<"type">>, <<"text/css">>), + ?XMLATTR(<<"rel">>, <<"stylesheet">>)]}]}, ?XE('body', [?XAE('div', - [?XMLATTR('id', <<"container">>)], + [?XMLATTR(<<"id">>, <<"container">>)], [?XAE('div', - [?XMLATTR('id', <<"header">>)], + [?XMLATTR(<<"id">>, <<"header">>)], [?XE('h1', [?ACT("/admin/", "ejabberd Web Admin")] )]), ?XAE('div', - [?XMLATTR('id', <<"navigation">>)], + [?XMLATTR(<<"id">>, <<"navigation">>)], [?XE('ul', MenuItems )]), ?XAE('div', - [?XMLATTR('id', <<"content">>)], + [?XMLATTR(<<"id">>, <<"content">>)], Els), ?XAE('div', - [?XMLATTR('id', <<"clearcopyright">>)], + [?XMLATTR(<<"id">>, <<"clearcopyright">>)], [#xmlcdata{cdata = <<>>}])]), ?XAE('div', - [?XMLATTR('id', <<"copyrightouter">>)], + [?XMLATTR(<<"id">>, <<"copyrightouter">>)], [?XAE('div', - [?XMLATTR('id', <<"copyright">>)], + [?XMLATTR(<<"id">>, <<"copyright">>)], [?XC('p', "ejabberd (c) 2002-2010 ProcessOne") ])])]) @@ -837,7 +837,7 @@ process_admin(Host, error -> [?XREST("Bad format")]; nothing -> [] end ++ - [?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + [?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [?TEXTAREA("acls", integer_to_list(lists:max([16, NumLines])), "80", ACLsP++"."), ?BR, ?INPUTT("submit", "submit", "Submit") @@ -879,7 +879,7 @@ process_admin(Host, nothing -> [] end ++ [?XE('p', [?ACT("../acls-raw/", "Raw")])] ++ - [?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + [?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [acls_to_xhtml(ACLs), ?BR, ?INPUTT("submit", "delete", "Delete Selected"), @@ -946,7 +946,7 @@ process_admin(Host, error -> [?XREST("Bad format")]; nothing -> [] end ++ - [?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + [?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [?TEXTAREA("access", integer_to_list(lists:max([16, NumLines])), "80", AccessP++"."), ?BR, ?INPUTT("submit", "submit", "Submit") @@ -983,7 +983,7 @@ process_admin(Host, nothing -> [] end ++ [?XE('p', [?ACT("../access-raw/", "Raw")])] ++ - [?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + [?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [access_rules_to_xhtml(AccessRules, Lang), ?BR, ?INPUTT("submit", "delete", "Delete Selected") @@ -1023,7 +1023,7 @@ process_admin(Host, error -> [?XREST("Bad format")]; nothing -> [] end ++ - [?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + [?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [access_rule_to_xhtml(Rules), ?BR, ?INPUTT("submit", "submit", "Submit") @@ -1079,17 +1079,17 @@ process_admin(Host, list_last_activity(Host, Lang, true, Month) end, make_xhtml([?XCT('h1', "Users Last Activity")] ++ - [?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + [?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [?CT("Period: "), - ?XAE('select', [?XMLATTR('name', <<"period">>)], + ?XAE('select', [?XMLATTR(<<"name">>, <<"period">>)], lists:map( fun({O, V}) -> Sel = if - O == Month -> [?XMLATTR('selected', <<"selected">>)]; + O == Month -> [?XMLATTR(<<"selected">>, <<"selected">>)]; true -> [] end, ?XAC('option', - Sel ++ [?XMLATTR('value', O)], V) + Sel ++ [?XMLATTR(<<"value">>, O)], V) end, [{"month", ?T("Last month")}, {"year", ?T("Last year")}, {"all", ?T("All activity")}])), @@ -1245,15 +1245,15 @@ acl_spec_to_xhtml(ID, Spec) -> acl_spec_select(ID, Opt) -> ?XE('td', - [?XAE('select', [?XMLATTR('name', "type" ++ ID)], + [?XAE('select', [?XMLATTR(<<"name">>, "type" ++ ID)], lists:map( fun(O) -> Sel = if - O == Opt -> [?XMLATTR('selected', <<"selected">>)]; + O == Opt -> [?XMLATTR(<<"selected">>, <<"selected">>)]; true -> [] end, ?XAC('option', - Sel ++ [?XMLATTR('value', O)], + Sel ++ [?XMLATTR(<<"value">>, O)], atom_to_list(O)) end, [user, server, user_regexp, server_regexp, node_regexp, user_glob, server_glob, node_glob, all, raw]))]). @@ -1454,9 +1454,9 @@ access_rule_to_xhtml(Rules) -> SACL = atom_to_list(ACL), SAccess ++ "\s\t" ++ SACL ++ "\n" end, Rules), - ?XAC('textarea', [?XMLATTR('name', <<"rules">>), - ?XMLATTR('rows', <<"16">>), - ?XMLATTR('cols', <<"80">>)], + ?XAC('textarea', [?XMLATTR(<<"name">>, <<"rules">>), + ?XMLATTR(<<"rows">>, <<"16">>), + ?XMLATTR(<<"cols">>, <<"80">>)], Text). parse_access_rule(Text) -> @@ -1546,7 +1546,7 @@ list_users(Host, Query, Lang, URLFunc) -> error -> [?XREST("Bad format")]; nothing -> [] end ++ - [?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + [?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [?XE('table', [?XE('tr', [?XC('td', ?T("User") ++ ":"), @@ -1560,7 +1560,7 @@ list_users(Host, Query, Lang, URLFunc) -> ]), ?XE('tr', [?X('td'), - ?XAE('td', [?XMLATTR('class', <<"alignright">>)], + ?XAE('td', [?XMLATTR(<<"class">>, <<"alignright">>)], [?INPUTT("submit", "addnewuser", "Add User")]), ?X('td') ])]), @@ -1796,7 +1796,7 @@ user_info(User, Server, Query, Lang) -> error -> [?XREST("Bad format")]; nothing -> [] end ++ - [?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + [?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [?XCT('h3', "Connected Resources:")] ++ FResources ++ [?XCT('h3', "Password:")] ++ FPassword ++ [?XCT('h3', "Last Activity")] ++ [?C(LastActivity)] ++ @@ -1876,9 +1876,9 @@ list_last_activity(Host, Lang, Integral, Period) -> end, Max = lists:max(Hist), [?XAE('ol', - [?XMLATTR('id', <<"lastactivity">>), ?XMLATTR('start', <<"0">>)], + [?XMLATTR(<<"id">>, <<"lastactivity">>), ?XMLATTR(<<"start">>, <<"0">>)], [?XAE('li', - [?XMLATTR('style', + [?XMLATTR(<<"style">>, "width:" ++ integer_to_list( trunc(90 * V / Max)) ++ "%;")], [#xmlcdata{cdata = list_to_binary(pretty_string_int(V))}]) @@ -1934,13 +1934,13 @@ get_miscopts(Lang, Method, Query) -> end ++ [ ?XCT("h2", "Global"), - ?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + ?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [options_to_xhtml("global", GlobalOptions, Lang), ?BR, ?INPUTT("submit", "deleteglobal", "Delete Selected") ]), ?XCT("h2", "Local"), - ?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + ?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [options_to_xhtml("local", LocalOptions, Lang), ?BR, ?INPUTT("submit", "deletelocal", "Delete Selected") @@ -2076,7 +2076,7 @@ get_miscopt(Lang, Query, SType, OldSKey) -> nothing -> [] end ++ [?XCT("h2", UpSType), - ?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + ?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [?TEXTAREA("miscopt", integer_to_list(lists:max([16, NumLines])), "80", SOpt++"."), ?BR, @@ -2163,7 +2163,7 @@ get_node(global, Node, [], Query, Lang) -> ?LI([?ACT(Base ++ "stats/", "Statistics")]), ?LI([?ACT(Base ++ "update/", "Update")]) ] ++ MenuItems2), - ?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + ?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [?INPUTT('submit', "restart", "Restart"), ?C(" "), ?INPUTT('submit', "stop", "Stop")]) @@ -2215,15 +2215,15 @@ get_node(global, Node, ["db"], Query, Lang) -> [?XC('td', STable), ?XE('td', [db_storage_select( STable, Type, Lang)]), - ?XAC('td', [?XMLATTR('class', <<"alignright">>)], + ?XAC('td', [?XMLATTR(<<"class">>, <<"alignright">>)], pretty_string_int(Size)), - ?XAC('td', [?XMLATTR('class', <<"alignright">>)], + ?XAC('td', [?XMLATTR(<<"class">>, <<"alignright">>)], pretty_string_int(Memory)) ]) end, STables), [?XC('h1', ?T("Database Tables at ") ++ atom_to_list(Node))] ++ ResS ++ - [?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + [?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [?XAE('table', [], [?XE('thead', [?XE('tr', @@ -2235,8 +2235,8 @@ get_node(global, Node, ["db"], Query, Lang) -> ?XE('tbody', Rows ++ [?XE('tr', - [?XAE('td', [?XMLATTR('colspan', <<"4">>), - ?XMLATTR('class', <<"alignright">>)], + [?XAE('td', [?XMLATTR(<<"colspan">>, <<"4">>), + ?XMLATTR(<<"class">>, <<"alignright">>)], [?INPUTT("submit", "submit", "Submit")]) ])] @@ -2258,7 +2258,7 @@ get_node(global, Node, ["backup"], Query, Lang) -> [?XC('h1', ?T("Backup of ") ++ atom_to_list(Node))] ++ ResS ++ [?XCT('p', "Please note that these options will only backup the builtin Mnesia database. If you are using the ODBC module, you also need to backup your SQL database separately."), - ?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + ?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [?XAE('table', [], [?XE('tbody', [?XE('tr', @@ -2351,7 +2351,7 @@ get_node(global, Node, ["pid"], _Query, Lang) -> ?XAE('table', [], [?XE('tbody', [?XE('tr', [?XCT('td', "Number of processes:"), - ?XAC('td', [?XMLATTR('class', <<"alignright">>)], + ?XAC('td', [?XMLATTR(<<"class">>, <<"alignright">>)], pretty_string_int(ProcessesNumber))]) ]) ]), @@ -2426,7 +2426,7 @@ get_node(global, Node, ["ports"], Query, Lang) -> {error, ReasonT} -> [?XRES(?T("Error") ++ ": " ++ ReasonT)]; nothing -> [] end ++ - [?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + [?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [node_ports_to_xhtml(NewPorts, Lang)]) ]; @@ -2450,7 +2450,7 @@ get_node(Host, Node, ["modules"], Query, Lang) when is_list(Host) -> error -> [?XREST("Bad format")]; nothing -> [] end ++ - [?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + [?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [node_modules_to_xhtml(NewModules, Lang)]) ]; @@ -2473,25 +2473,25 @@ get_node(global, Node, ["stats"], _Query, Lang) -> ?XAE('table', [], [?XE('tbody', [?XE('tr', [?XCT('td', "Uptime:"), - ?XAC('td', [?XMLATTR('class', <<"alignright">>)], + ?XAC('td', [?XMLATTR(<<"class">>, <<"alignright">>)], UpTimeS)]), ?XE('tr', [?XCT('td', "CPU Time:"), - ?XAC('td', [?XMLATTR('class', <<"alignright">>)], + ?XAC('td', [?XMLATTR(<<"class">>, <<"alignright">>)], CPUTimeS)]), ?XE('tr', [?XCT('td', "Online Users:"), - ?XAC('td', [?XMLATTR('class', <<"alignright">>)], + ?XAC('td', [?XMLATTR(<<"class">>, <<"alignright">>)], pretty_string_int(OnlineUsers))]), ?XE('tr', [?XCT('td', "Transactions Committed:"), - ?XAC('td', [?XMLATTR('class', <<"alignright">>)], + ?XAC('td', [?XMLATTR(<<"class">>, <<"alignright">>)], pretty_string_int(TransactionsCommitted))]), ?XE('tr', [?XCT('td', "Transactions Aborted:"), - ?XAC('td', [?XMLATTR('class', <<"alignright">>)], + ?XAC('td', [?XMLATTR(<<"class">>, <<"alignright">>)], pretty_string_int(TransactionsAborted))]), ?XE('tr', [?XCT('td', "Transactions Restarted:"), - ?XAC('td', [?XMLATTR('class', <<"alignright">>)], + ?XAC('td', [?XMLATTR(<<"class">>, <<"alignright">>)], pretty_string_int(TransactionsRestarted))]), ?XE('tr', [?XCT('td', "Transactions Logged:"), - ?XAC('td', [?XMLATTR('class', <<"alignright">>)], + ?XAC('td', [?XMLATTR(<<"class">>, <<"alignright">>)], pretty_string_int(TransactionsLogged))]) ]) ])]; @@ -2525,13 +2525,13 @@ get_node(global, Node, ["update"], Query, Lang) -> [?BR, ?INPUTATTRS(<<"button">>, <<"selectall">>, <<"Select All">>, - [?XMLATTR('onClick', <<"selectAll()">>)]), + [?XMLATTR(<<"onClick">>, <<"selectAll()">>)]), ?C(" "), ?INPUTATTRS(<<"button">>, <<"unselectall">>, <<"Unselect All">>, - [?XMLATTR('onClick', <<"unSelectAll()">>)])], + [?XMLATTR(<<"onClick">>, <<"unSelectAll()">>)])], %%?XE("ul", BeamsLis) - ?XAE('ul', [?XMLATTR('class', <<"noliststyle">>)], + ?XAE('ul', [?XMLATTR(<<"class">>, <<"noliststyle">>)], BeamsLis ++ SelectButtons) end, FmtScript = ?XC('pre', io_lib:format("~p", [Script])), @@ -2542,7 +2542,7 @@ get_node(global, Node, ["update"], Query, Lang) -> {error, ErrorText} -> [?XREST("Error: " ++ ErrorText)]; nothing -> [] end ++ - [?XAE('form', [?XMLATTR('action', <<>>), ?XMLATTR('method', <<"post">>)], + [?XAE('form', [?XMLATTR(<<"action">>, <<>>), ?XMLATTR(<<"method">>, <<"post">>)], [ ?XCT('h2', "Update plan"), ?XCT('h3', "Modified modules"), Mods, @@ -2592,15 +2592,15 @@ node_parse_query(Node, Query) -> db_storage_select(ID, Opt, Lang) -> - ?XAE('select', [?XMLATTR('name', "table" ++ ID)], + ?XAE('select', [?XMLATTR(<<"name">>, "table" ++ ID)], lists:map( fun({O, Desc}) -> Sel = if - O == Opt -> [?XMLATTR('selected', <<"selected">>)]; + O == Opt -> [?XMLATTR(<<"selected">>, <<"selected">>)]; true -> [] end, ?XACT('option', - Sel ++ [?XMLATTR('value', O)], + Sel ++ [?XMLATTR(<<"value">>, O)], Desc) end, [{ram_copies, "RAM copy"}, {disc_copies, "RAM and disc copy"}, @@ -2713,7 +2713,7 @@ node_backup_parse_query(Node, Query) -> "import_piefxis_file", "export_piefxis_dir", "export_piefxis_host_dir"]). node_ports_to_xhtml(Ports, Lang) -> - ?XAE('table', [?XMLATTR('class', <<"withtextareas">>)], + ?XAE('table', [?XMLATTR(<<"class">>, <<"withtextareas">>)], [?XE('thead', [?XE('tr', [?XCT('td', "Port"), @@ -2731,9 +2731,9 @@ node_ports_to_xhtml(Ports, Lang) -> {NumLines, SOptsClean} = term_to_paragraph(OptsClean, 40), %%ID = term_to_id(E), ?XE('tr', - [?XAE('td', [?XMLATTR('size', <<"6">>)], [?C(SPort)]), - ?XAE('td', [?XMLATTR('size', <<"15">>)], [?C(SIP)]), - ?XAE('td', [?XMLATTR('size', <<"4">>)], [?C(atom_to_list(NetProt))]), + [?XAE('td', [?XMLATTR(<<"size">>, <<"6">>)], [?C(SPort)]), + ?XAE('td', [?XMLATTR(<<"size">>, <<"15">>)], [?C(SIP)]), + ?XAE('td', [?XMLATTR(<<"size">>, <<"4">>)], [?C(atom_to_list(NetProt))]), ?XE('td', [?INPUTS("text", "module" ++ SSPort, SModule, "15")]), ?XE('td', [?TEXTAREA("opts" ++ SSPort, integer_to_list(NumLines), "35", SOptsClean)]), @@ -2750,22 +2750,22 @@ node_ports_to_xhtml(Ports, Lang) -> ?XE("td", [make_netprot_html("tcp")]), ?XE('td', [?INPUTS("text", "modulenew", "", "15")]), ?XE('td', [?TEXTAREA("optsnew", "2", "35", "[]")]), - ?XAE('td', [?XMLATTR("colspan", "2")], + ?XAE('td', [?XMLATTR(<<"colspan">>, "2")], [?INPUTT("submit", "addnew", "Add New")]) ] )] )]). make_netprot_html(NetProt) -> - ?XAE('select', [?XMLATTR('name', "netprotnew")], + ?XAE('select', [?XMLATTR(<<"name">>, "netprotnew")], lists:map( fun(O) -> Sel = if - O == NetProt -> [?XMLATTR('selected', <<"selected">>)]; + O == NetProt -> [?XMLATTR(<<"selected">>, <<"selected">>)]; true -> [] end, ?XAC('option', - Sel ++ [?XMLATTR('value', O)], + Sel ++ [?XMLATTR(<<"value">>, O)], O) end, ["tcp", "udp"])). @@ -2843,7 +2843,7 @@ node_ports_parse_query(Node, Ports, Query) -> end. node_modules_to_xhtml(Modules, Lang) -> - ?XAE('table', [?XMLATTR('class', <<"withtextareas">>)], + ?XAE('table', [?XMLATTR(<<"class">>, <<"withtextareas">>)], [?XE('thead', [?XE('tr', [?XCT('td', "Module"), @@ -2868,7 +2868,7 @@ node_modules_to_xhtml(Modules, Lang) -> [?XE('tr', [?XE('td', [?INPUT("text", "modulenew", "")]), ?XE('td', [?TEXTAREA("optsnew", "2", "40", "[]")]), - ?XAE('td', [?XMLATTR("colspan", "2")], + ?XAE('td', [?XMLATTR(<<"colspan">>, "2")], [?INPUTT("submit", "start", "Start")]) ] )] @@ -3103,17 +3103,17 @@ make_menu_items2(Lang, Deep, {MURI, MName, [Item | Items]}, Res) -> make_menu_items2(Lang, Deep, {MURI, MName, Items}, Res2). make_menu_item(header, 1, URI, Name, _Lang) -> - ?LI([?XAE('div', [?XMLATTR('id', <<"navhead">>)], [?AC(URI, Name)] )]); + ?LI([?XAE('div', [?XMLATTR(<<"id">>, <<"navhead">>)], [?AC(URI, Name)] )]); make_menu_item(header, 2, URI, Name, _Lang) -> - ?LI([?XAE('div', [?XMLATTR('id', <<"navheadsub">>)], [?AC(URI, Name)] )]); + ?LI([?XAE('div', [?XMLATTR(<<"id">>, <<"navheadsub">>)], [?AC(URI, Name)] )]); make_menu_item(header, 3, URI, Name, _Lang) -> - ?LI([?XAE('div', [?XMLATTR('id', <<"navheadsubsub">>)], [?AC(URI, Name)] )]); + ?LI([?XAE('div', [?XMLATTR(<<"id">>, <<"navheadsubsub">>)], [?AC(URI, Name)] )]); make_menu_item(item, 1, URI, Name, Lang) -> - ?LI([?XAE('div', [?XMLATTR('id', <<"navitem">>)], [?ACT(URI, Name)] )]); + ?LI([?XAE('div', [?XMLATTR(<<"id">>, <<"navitem">>)], [?ACT(URI, Name)] )]); make_menu_item(item, 2, URI, Name, Lang) -> - ?LI([?XAE('div', [?XMLATTR('id', <<"navitemsub">>)], [?ACT(URI, Name)] )]); + ?LI([?XAE('div', [?XMLATTR(<<"id">>, <<"navitemsub">>)], [?ACT(URI, Name)] )]); make_menu_item(item, 3, URI, Name, Lang) -> - ?LI([?XAE('div', [?XMLATTR('id', <<"navitemsubsub">>)], [?ACT(URI, Name)] )]). + ?LI([?XAE('div', [?XMLATTR(<<"id">>, <<"navitemsubsub">>)], [?ACT(URI, Name)] )]). %%%================================== diff --git a/src/web/mod_http_bind.erl b/src/web/mod_http_bind.erl index aa4f1dedf..7edd88a8b 100644 --- a/src/web/mod_http_bind.erl +++ b/src/web/mod_http_bind.erl @@ -86,7 +86,7 @@ get_human_html_xmlel() -> Par1 = #xmlel{name = p, children = [#xmlcdata{cdata = <<"An implementation of ">>}, #xmlel{name = a, - attrs = [#xmlattr{name=href, value = <<"http://xmpp.org/extensions/xep-0206.html">>}], + attrs = [#xmlattr{name = <<"href">>, value = <<"http://xmpp.org/extensions/xep-0206.html">>}], children = [#xmlcdata{cdata = <<"XMPP over BOSH (XEP-0206)">>}] } ]}, @@ -95,7 +95,7 @@ get_human_html_xmlel() -> "To use HTTP-Bind you need a Jabber/XMPP client that supports it.">>} ]}, #xmlel{name = html, - attrs = [#xmlattr{name = xmlns, value= <<"http://www.w3.org/1999/xhtml">>}], + attrs = [#xmlattr{name = <<"xmlns">>, value= <<"http://www.w3.org/1999/xhtml">>}], children = [#xmlel{name = head, children = [#xmlel{name = title, children = [#xmlcdata{cdata = Heading}]}]}, #xmlel{name = body, children = [H, Par1, Par2]}]}. diff --git a/src/web/mod_register_web.erl b/src/web/mod_register_web.erl index b5e1f2710..c86405e78 100644 --- a/src/web/mod_register_web.erl +++ b/src/web/mod_register_web.erl @@ -159,13 +159,13 @@ css() -> %%%---------------------------------------------------------------------- make_xa_link_css() -> - ?XA('link', [?XMLATTR('href', <<"/register/register.css">>), - ?XMLATTR('type', <<"text/css">>), - ?XMLATTR('rel', <<"stylesheet">>)]). + ?XA('link', [?XMLATTR(<<"href">>, <<"/register/register.css">>), + ?XMLATTR(<<"type">>, <<"text/css">>), + ?XMLATTR(<<"rel">>, <<"stylesheet">>)]). make_h1_title(TextString, Lang) -> ?XACT('h1', - [?XMLATTR('class', <<"title">>), ?XMLATTR('style', <<"text-align:center;">>)], + [?XMLATTR(<<"class">>, <<"title">>), ?XMLATTR(<<"style">>, <<"text-align:center;">>)], TextString). index_page(Lang) -> @@ -205,7 +205,7 @@ form_new_get(Host, Lang) -> "Please read carefully the instructions to fill correctly the fields."), %% - ?XAE('form', [?XMLATTR('action', <<"">>), ?XMLATTR('method', <<"post">>)], + ?XAE('form', [?XMLATTR(<<"action">>, <<"">>), ?XMLATTR(<<"method">>, <<"post">>)], [ ?XE('ol', [ ?XE('li', [ @@ -364,7 +364,7 @@ form_changepass_get(Host, Lang) -> ], Els=[ make_h1_title("Change Password", Lang), - ?XAE('form', [?XMLATTR('action', <<"">>), ?XMLATTR('method', <<"post">>)], + ?XAE('form', [?XMLATTR(<<"action">>, <<"">>), ?XMLATTR(<<"method">>, <<"post">>)], [ ?XE('ol', [ ?XE('li', [ @@ -482,7 +482,7 @@ form_del_get(Host, Lang) -> make_h1_title("Unregister a Jabber account", Lang), ?XCT('p', "This page allows to unregister a Jabber account in this Jabber server."), - ?XAE('form', [?XMLATTR('action', <<"">>), ?XMLATTR('method', <<"post">>)], + ?XAE('form', [?XMLATTR(<<"action">>, <<"">>), ?XMLATTR(<<"method">>, <<"post">>)], [ ?XE('ol', [ ?XE('li', [