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

o Use the new exmpp namespace macro names.

o  Update send_element/2 to use exmpp new to_list functions.

SVN Revision: 1384
This commit is contained in:
Jean-Sébastien Pédron 2008-06-27 13:46:08 +00:00
parent 22e79490ff
commit b32aba27c1
4 changed files with 71 additions and 64 deletions

View File

@ -1,3 +1,9 @@
2008-06-27 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/ejabberd_c2s.erl, src/ejabberd_s2s_out.erl,
src/ejabberd_s2s_in.erl: Use the new exmpp namespace macro names.
Update send_element/2 to use exmpp new to_list functions.
2008-06-26 Jean-Sébastien Pédron <js.pedron@meetic-corp.com> 2008-06-26 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/ejabberd_c2s.erl: Use a macro in ?DEFAULT_NS instead of the * src/ejabberd_c2s.erl: Use a macro in ?DEFAULT_NS instead of the

View File

@ -116,11 +116,8 @@
% These are the namespace already declared by the stream opening. This is % These are the namespace already declared by the stream opening. This is
% used at serialization time. % used at serialization time.
-define(DEFAULT_NS, [?NS_JABBER_CLIENT]). -define(DEFAULT_NS, ?NS_JABBER_CLIENT).
-define(PREFIXED_NS, [{?NS_XMPP, "stream"}]). -define(PREFIXED_NS, [{?NS_XMPP, ?NS_XMPP_pfx}]).
% XXX OLD FORMAT
-define(NS_AUTH, "jabber:iq:auth").
-define(STANZA_ERROR(Condition), -define(STANZA_ERROR(Condition),
exmpp_xml:xmlel_to_xmlelement(exmpp_stanza:error(Condition), exmpp_xml:xmlel_to_xmlelement(exmpp_stanza:error(Condition),
@ -553,7 +550,7 @@ wait_for_feature_request({xmlstreamelement, #xmlel{ns = NS, name = Name} = El},
end, end,
Socket = StateData#state.socket, Socket = StateData#state.socket,
Proceed = exmpp_xml:document_fragment_to_list( Proceed = exmpp_xml:document_fragment_to_list(
exmpp_server_tls:proceed(), ?DEFAULT_NS, ?PREFIXED_NS), exmpp_server_tls:proceed(), [?DEFAULT_NS], ?PREFIXED_NS),
TLSSocket = (StateData#state.sockmod):starttls( TLSSocket = (StateData#state.sockmod):starttls(
Socket, TLSOpts, Socket, TLSOpts,
Proceed), Proceed),
@ -821,10 +818,10 @@ session_established({xmlstreamelement, El}, StateData) ->
c2s_update_presence, c2s_update_presence,
Server, Server,
exmpp_xml:xmlel_to_xmlelement(NewEl, exmpp_xml:xmlel_to_xmlelement(NewEl,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
[User, Server]), [User, Server]),
PresenceEl = exmpp_xml:xmlelement_to_xmlel(PresenceElOld, PresenceEl = exmpp_xml:xmlelement_to_xmlel(PresenceElOld,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
% XXX OLD FORMAT: PresenceElOld, *JID. % XXX OLD FORMAT: PresenceElOld, *JID.
FromJIDOld = exmpp_jid:to_ejabberd_jid(FromJID), FromJIDOld = exmpp_jid:to_ejabberd_jid(FromJID),
ToJIDOld = exmpp_jid:to_ejabberd_jid(ToJID), ToJIDOld = exmpp_jid:to_ejabberd_jid(ToJID),
@ -849,13 +846,13 @@ session_established({xmlstreamelement, El}, StateData) ->
FromJIDOld = exmpp_jid:to_ejabberd_jid(FromJID), FromJIDOld = exmpp_jid:to_ejabberd_jid(FromJID),
ToJIDOld = exmpp_jid:to_ejabberd_jid(ToJID), ToJIDOld = exmpp_jid:to_ejabberd_jid(ToJID),
case exmpp_iq:get_payload(El) of case exmpp_iq:get_payload(El) of
#xmlel{ns = ?NS_JABBER_PRIVACY} -> #xmlel{ns = ?NS_PRIVACY} ->
process_privacy_iq( process_privacy_iq(
FromJID, ToJID, El, StateData); FromJID, ToJID, El, StateData);
_ -> _ ->
% XXX OLD FORMAT: NewElOld. % XXX OLD FORMAT: NewElOld.
NewElOld = exmpp_xml:xmlel_to_xmlelement(NewEl, NewElOld = exmpp_xml:xmlel_to_xmlelement(NewEl,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
ejabberd_hooks:run( ejabberd_hooks:run(
user_send_packet, user_send_packet,
Server, Server,
@ -868,7 +865,7 @@ session_established({xmlstreamelement, El}, StateData) ->
#xmlel{ns = ?NS_JABBER_CLIENT, name = 'message'} -> #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message'} ->
% XXX OLD FORMAT: NewElOld, JIDs. % XXX OLD FORMAT: NewElOld, JIDs.
NewElOld = exmpp_xml:xmlel_to_xmlelement(NewEl, NewElOld = exmpp_xml:xmlel_to_xmlelement(NewEl,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
FromJIDOld = exmpp_jid:to_ejabberd_jid(FromJID), FromJIDOld = exmpp_jid:to_ejabberd_jid(FromJID),
ToJIDOld = exmpp_jid:to_ejabberd_jid(ToJID), ToJIDOld = exmpp_jid:to_ejabberd_jid(ToJID),
ejabberd_hooks:run(user_send_packet, ejabberd_hooks:run(user_send_packet,
@ -882,7 +879,7 @@ session_established({xmlstreamelement, El}, StateData) ->
end, end,
% XXX OLD FORMAT: El. % XXX OLD FORMAT: El.
ElOld = exmpp_xml:xmlel_to_xmlelement(El, ElOld = exmpp_xml:xmlel_to_xmlelement(El,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
ejabberd_hooks:run(c2s_loop_debug, [{xmlstreamelement, ElOld}]), ejabberd_hooks:run(c2s_loop_debug, [{xmlstreamelement, ElOld}]),
fsm_next_state(session_established, NewState) fsm_next_state(session_established, NewState)
catch catch
@ -898,7 +895,7 @@ session_established({xmlstreamelement, El}, StateData) ->
end, end,
% XXX OLD FORMAT: ElOld1. % XXX OLD FORMAT: ElOld1.
ElOld1 = exmpp_xml:xmlel_to_xmlelement(El, ElOld1 = exmpp_xml:xmlel_to_xmlelement(El,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
ejabberd_hooks:run(c2s_loop_debug, [{xmlstreamelement, ElOld1}]), ejabberd_hooks:run(c2s_loop_debug, [{xmlstreamelement, ElOld1}]),
fsm_next_state(session_established, StateData); fsm_next_state(session_established, StateData);
throw:Exception -> throw:Exception ->
@ -1014,7 +1011,7 @@ handle_info(replaced, _StateName, StateData) ->
handle_info({route, FromOld, ToOld, PacketOld}, StateName, StateData) -> handle_info({route, FromOld, ToOld, PacketOld}, StateName, StateData) ->
%% XXX OLD FORMAT: From, To and Packet are in the old format. %% XXX OLD FORMAT: From, To and Packet are in the old format.
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld, Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
From = exmpp_jid:from_ejabberd_jid(FromOld), From = exmpp_jid:from_ejabberd_jid(FromOld),
To = exmpp_jid:from_ejabberd_jid(ToOld), To = exmpp_jid:from_ejabberd_jid(ToOld),
{Pass, NewAttrs, NewState} = {Pass, NewAttrs, NewState} =
@ -1191,7 +1188,7 @@ handle_info({route, FromOld, ToOld, PacketOld}, StateName, StateData) ->
Res = exmpp_iq:error(Packet, Err), Res = exmpp_iq:error(Packet, Err),
% XXX OLD FORMAT: To, From, Res. % XXX OLD FORMAT: To, From, Res.
ResOld = exmpp_xml:xmlel_to_xmlelement( ResOld = exmpp_xml:xmlel_to_xmlelement(
Res, ?DEFAULT_NS, ?PREFIXED_NS), Res, [?DEFAULT_NS], ?PREFIXED_NS),
ejabberd_router:route(ToOld, FromOld, ResOld) ejabberd_router:route(ToOld, FromOld, ResOld)
end, end,
{false, Attrs, StateData}; {false, Attrs, StateData};
@ -1214,7 +1211,7 @@ handle_info({route, FromOld, ToOld, PacketOld}, StateName, StateData) ->
% XXX OLD FORMAT: To, From, Res. % XXX OLD FORMAT: To, From, Res.
ResOld = exmpp_xml:xmlel_to_xmlelement( ResOld = exmpp_xml:xmlel_to_xmlelement(
Res, Res,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
ejabberd_router:route(ToOld, FromOld, ResOld), ejabberd_router:route(ToOld, FromOld, ResOld),
{false, Attrs, StateData} {false, Attrs, StateData}
end end
@ -1251,7 +1248,7 @@ handle_info({route, FromOld, ToOld, PacketOld}, StateName, StateData) ->
send_element(StateData, FixedPacket), send_element(StateData, FixedPacket),
% XXX OLD FORMAT: From, To, FixedPacket. % XXX OLD FORMAT: From, To, FixedPacket.
FixedPacketOld = exmpp_xml:xmlel_to_xmlelement(FixedPacket, FixedPacketOld = exmpp_xml:xmlel_to_xmlelement(FixedPacket,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
ejabberd_hooks:run(user_receive_packet, ejabberd_hooks:run(user_receive_packet,
StateData#state.server, StateData#state.server,
[StateData#state.jid, FromOld, ToOld, FixedPacketOld]), [StateData#state.jid, FromOld, ToOld, FixedPacketOld]),
@ -1349,13 +1346,11 @@ send_text(StateData, Text) ->
(StateData#state.sockmod):send(StateData#state.socket, Text). (StateData#state.sockmod):send(StateData#state.socket, Text).
send_element(StateData, #xmlel{ns = ?NS_XMPP, name = 'stream'} = El) -> send_element(StateData, #xmlel{ns = ?NS_XMPP, name = 'stream'} = El) ->
send_text(StateData, exmpp_xml:document_to_list(El)); send_text(StateData, exmpp_stream:to_list(El));
send_element(StateData, #xmlel{ns = ?NS_JABBER_SERVER} = El) -> send_element(StateData, #xmlel{ns = ?NS_JABBER_SERVER} = El) ->
send_text(StateData, exmpp_xml:document_fragment_to_list(El, send_text(StateData, exmpp_stanza:to_list(El, ?NS_JABBER_SERVER));
[?NS_JABBER_SERVER], ?PREFIXED_NS));
send_element(StateData, El) -> send_element(StateData, El) ->
send_text(StateData, exmpp_xml:document_fragment_to_list(El, send_text(StateData, exmpp_stanza:to_list(El, ?DEFAULT_NS)).
?DEFAULT_NS, ?PREFIXED_NS)).
new_id() -> new_id() ->
@ -1365,9 +1360,10 @@ new_id() ->
is_auth_packet(El) -> is_auth_packet(El) ->
% XXX OLD FORMAT: El. % XXX OLD FORMAT: El.
ElOld = exmpp_xml:xmlel_to_xmlelement(El, ElOld = exmpp_xml:xmlel_to_xmlelement(El,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
NS_Auth = atom_to_list(?NS_LEGACY_AUTH),
case jlib:iq_query_info(ElOld) of case jlib:iq_query_info(ElOld) of
#iq{id = ID, type = Type, xmlns = ?NS_AUTH, sub_el = SubEl} -> #iq{id = ID, type = Type, xmlns = NS_Auth, sub_el = SubEl} ->
{xmlelement, _, _, Els} = SubEl, {xmlelement, _, _, Els} = SubEl,
{auth, ID, Type, {auth, ID, Type,
get_auth_tags(Els, "", "", "", undefined)}; get_auth_tags(Els, "", "", "", undefined)};
@ -1432,7 +1428,7 @@ process_presence_probe(From, To, StateData) ->
FromOld = exmpp_jid:to_ejabberd_jid(From), FromOld = exmpp_jid:to_ejabberd_jid(From),
ToOld = exmpp_jid:to_ejabberd_jid(To), ToOld = exmpp_jid:to_ejabberd_jid(To),
PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet, PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
case ejabberd_hooks:run_fold( case ejabberd_hooks:run_fold(
privacy_check_packet, StateData#state.server, privacy_check_packet, StateData#state.server,
allow, allow,
@ -1462,7 +1458,7 @@ process_presence_probe(From, To, StateData) ->
FromOld = exmpp_jid:to_ejabberd_jid(From), FromOld = exmpp_jid:to_ejabberd_jid(From),
ToOld = exmpp_jid:to_ejabberd_jid(To), ToOld = exmpp_jid:to_ejabberd_jid(To),
PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet, PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
ejabberd_router:route(ToOld, FromOld, PacketOld); ejabberd_router:route(ToOld, FromOld, PacketOld);
true -> true ->
ok ok
@ -1591,7 +1587,7 @@ presence_track(From, To, Packet, StateData) ->
BFromOld = exmpp_jid:to_ejabberd_jid(exmpp_jid:jid_to_bare_jid(From)), BFromOld = exmpp_jid:to_ejabberd_jid(exmpp_jid:jid_to_bare_jid(From)),
ToOld = exmpp_jid:to_ejabberd_jid(To), ToOld = exmpp_jid:to_ejabberd_jid(To),
PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet, PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
case exmpp_presence:get_type(Packet) of case exmpp_presence:get_type(Packet) of
'unavailable' -> 'unavailable' ->
% XXX OLD FORMAT: From, To, Packet. % XXX OLD FORMAT: From, To, Packet.
@ -1676,7 +1672,7 @@ presence_broadcast(StateData, From, JIDSet, Packet) ->
FJIDOld = exmpp_jid:to_ejabberd_jid(FJID), FJIDOld = exmpp_jid:to_ejabberd_jid(FJID),
FromOld = exmpp_jid:to_ejabberd_jid(From), FromOld = exmpp_jid:to_ejabberd_jid(From),
PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet, PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
case ejabberd_hooks:run_fold( case ejabberd_hooks:run_fold(
privacy_check_packet, StateData#state.server, privacy_check_packet, StateData#state.server,
allow, allow,
@ -1697,7 +1693,7 @@ presence_broadcast_to_trusted(StateData, From, T, A, Packet) ->
% XXX OLD FORMAT: From, Packet. % XXX OLD FORMAT: From, Packet.
FromOld = exmpp_jid:to_ejabberd_jid(From), FromOld = exmpp_jid:to_ejabberd_jid(From),
PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet, PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
lists:foreach( lists:foreach(
fun({U, S, R} = JID) -> fun({U, S, R} = JID) ->
case ?SETS:is_element(JID, T) of case ?SETS:is_element(JID, T) of
@ -1730,9 +1726,9 @@ presence_broadcast_first(From, StateData, Packet) ->
% XXX OLD FORMAT: From, Packet, Probe. % XXX OLD FORMAT: From, Packet, Probe.
FromOld = exmpp_jid:to_ejabberd_jid(From), FromOld = exmpp_jid:to_ejabberd_jid(From),
PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet, PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
ProbeOld = exmpp_xml:xmlel_to_xmlelement(Probe, ProbeOld = exmpp_xml:xmlel_to_xmlelement(Probe,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
?SETS:fold(fun({U, S, R}, X) -> ?SETS:fold(fun({U, S, R}, X) ->
FJID = exmpp_jid:make_jid(U, S, R), FJID = exmpp_jid:make_jid(U, S, R),
% XXX OLD FORMAT: FJID. % XXX OLD FORMAT: FJID.
@ -1821,7 +1817,7 @@ roster_change(IJID, ISubscription, StateData) ->
?DEBUG("C1: ~p~n", [LIJID]), ?DEBUG("C1: ~p~n", [LIJID]),
% XXX OLD FORMAT: P. % XXX OLD FORMAT: P.
POld = exmpp_xml:xmlelement_to_xmlel(P, POld = exmpp_xml:xmlelement_to_xmlel(P,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
% XXX OLD FORMAT: From, To, P. % XXX OLD FORMAT: From, To, P.
case ejabberd_hooks:run_fold( case ejabberd_hooks:run_fold(
privacy_check_packet, StateData#state.server, privacy_check_packet, StateData#state.server,
@ -1847,7 +1843,7 @@ roster_change(IJID, ISubscription, StateData) ->
PU = exmpp_presence:unavailable(), PU = exmpp_presence:unavailable(),
% XXX OLD FORMAT: PU. % XXX OLD FORMAT: PU.
PUOld = exmpp_xml:xmlelement_to_xmlel(PU, PUOld = exmpp_xml:xmlelement_to_xmlel(PU,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
% XXX OLD FORMAT: From, To, PU. % XXX OLD FORMAT: From, To, PU.
case ejabberd_hooks:run_fold( case ejabberd_hooks:run_fold(
privacy_check_packet, StateData#state.server, privacy_check_packet, StateData#state.server,
@ -1881,7 +1877,7 @@ update_priority(Priority, Packet, StateData) ->
Info = [{ip, StateData#state.ip},{conn, StateData#state.conn}], Info = [{ip, StateData#state.ip},{conn, StateData#state.conn}],
% XXX OLD FORMAT: Packet. % XXX OLD FORMAT: Packet.
PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet, PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
ejabberd_sm:set_presence(StateData#state.sid, ejabberd_sm:set_presence(StateData#state.sid,
StateData#state.user, StateData#state.user,
StateData#state.server, StateData#state.server,
@ -1895,7 +1891,7 @@ process_privacy_iq(From, To,
StateData) -> StateData) ->
% XXX OLD FORMAT: IQ is #iq. % XXX OLD FORMAT: IQ is #iq.
ElOld = exmpp_xml:xmlel_to_xmlelement(El, ElOld = exmpp_xml:xmlel_to_xmlelement(El,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
IQOld = jlib:iq_query_info(ElOld), IQOld = jlib:iq_query_info(ElOld),
% XXX OLD FORMAT: JIDs. % XXX OLD FORMAT: JIDs.
FromOld = exmpp_jid:to_ejabberd_jid(From), FromOld = exmpp_jid:to_ejabberd_jid(From),
@ -1923,16 +1919,16 @@ process_privacy_iq(From, To,
case Res of case Res of
{result, ResultOld} -> {result, ResultOld} ->
Result = exmpp_xml:xmlelement_to_xmlel(ResultOld, Result = exmpp_xml:xmlelement_to_xmlel(ResultOld,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
exmpp_iq:result(El, Result); exmpp_iq:result(El, Result);
{error, ErrorOld} -> {error, ErrorOld} ->
Error = exmpp_xml:xmlelement_to_xmlel(ErrorOld, Error = exmpp_xml:xmlelement_to_xmlel(ErrorOld,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
exmpp_iq:error(El, Error) exmpp_iq:error(El, Error)
end, end,
% XXX OLD FORMAT: To, From, IQRes. % XXX OLD FORMAT: To, From, IQRes.
IQResOld = exmpp_xml:xmlel_to_xmlelement(IQRes, IQResOld = exmpp_xml:xmlel_to_xmlelement(IQRes,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
ejabberd_router:route( ejabberd_router:route(
ToOld, FromOld, IQResOld), ToOld, FromOld, IQResOld),
NewStateData. NewStateData.
@ -1970,7 +1966,7 @@ resend_offline_messages(#state{user = User,
From = exmpp_jid:from_ejabberd_jid(FromOld), From = exmpp_jid:from_ejabberd_jid(FromOld),
To = exmpp_jid:from_ejabberd_jid(ToOld), To = exmpp_jid:from_ejabberd_jid(ToOld),
Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld, Packet = exmpp_xml:xmlelement_to_xmlel(PacketOld,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
Attrs1 = exmpp_stanza:set_sender_in_attrs( Attrs1 = exmpp_stanza:set_sender_in_attrs(
Packet#xmlel.attrs, From), Packet#xmlel.attrs, From),
Attrs2 = exmpp_stanza:set_recipient_in_attrs( Attrs2 = exmpp_stanza:set_recipient_in_attrs(
@ -1994,14 +1990,14 @@ resend_subscription_requests(#state{user = User,
% XXX OLD FORMAT ON DISK! % XXX OLD FORMAT ON DISK!
lists:foreach(fun(XMLPacketOld) -> lists:foreach(fun(XMLPacketOld) ->
XMLPacket = exmpp_xml:xmlelement_to_xmlel( XMLPacket = exmpp_xml:xmlelement_to_xmlel(
XMLPacketOld, ?DEFAULT_NS, ?PREFIXED_NS), XMLPacketOld, [?DEFAULT_NS], ?PREFIXED_NS),
send_element(StateData, send_element(StateData,
XMLPacket) XMLPacket)
end, end,
PendingSubscriptions). PendingSubscriptions).
process_unauthenticated_stanza(StateData, El) -> process_unauthenticated_stanza(StateData, El) ->
ElOld = exmpp_xml:xmlel_to_xmlelement(El, ?DEFAULT_NS, ?PREFIXED_NS), ElOld = exmpp_xml:xmlel_to_xmlelement(El, [?DEFAULT_NS], ?PREFIXED_NS),
case jlib:iq_query_info(ElOld) of case jlib:iq_query_info(ElOld) of
#iq{} = IQ -> #iq{} = IQ ->
ResOld = ejabberd_hooks:run_fold(c2s_unauthenticated_iq, ResOld = ejabberd_hooks:run_fold(c2s_unauthenticated_iq,
@ -2022,7 +2018,7 @@ process_unauthenticated_stanza(StateData, El) ->
send_element(StateData, Res2); send_element(StateData, Res2);
_ -> _ ->
Res = exmpp_xml:xmlelement_to_xmlel(ResOld, Res = exmpp_xml:xmlelement_to_xmlel(ResOld,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
send_element(StateData, Res) send_element(StateData, Res)
end; end;
_ -> _ ->

View File

@ -95,8 +95,10 @@
% These are the namespace already declared by the stream opening. This is % These are the namespace already declared by the stream opening. This is
% used at serialization time. % used at serialization time.
-define(DEFAULT_NS, [?NS_JABBER_SERVER]). -define(DEFAULT_NS, ?NS_JABBER_SERVER).
-define(PREFIXED_NS, [{?NS_XMPP, "stream"}, {?NS_JABBER_DIALBACK, "db"}]). -define(PREFIXED_NS, [
{?NS_XMPP, ?NS_XMPP_pfx}, {?NS_DIALBACK, ?NS_DIALBACK_pfx}
]).
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% API %%% API
@ -159,7 +161,7 @@ init([{SockMod, Socket}, Opts]) ->
wait_for_stream({xmlstreamstart, Opening}, StateData) -> wait_for_stream({xmlstreamstart, Opening}, StateData) ->
case {exmpp_stream:get_default_ns(Opening), case {exmpp_stream:get_default_ns(Opening),
exmpp_xml:is_ns_declared_here(Opening, ?NS_JABBER_DIALBACK), exmpp_xml:is_ns_declared_here(Opening, ?NS_DIALBACK),
exmpp_stream:get_version(Opening) == {1, 0}} of exmpp_stream:get_version(Opening) == {1, 0}} of
{?NS_JABBER_SERVER, _, true} when {?NS_JABBER_SERVER, _, true} when
StateData#state.tls and (not StateData#state.authenticated) -> StateData#state.tls and (not StateData#state.authenticated) ->
@ -240,7 +242,7 @@ wait_for_feature_request({xmlstreamelement, El}, StateData) ->
?DEBUG("starttls", []), ?DEBUG("starttls", []),
Socket = StateData#state.socket, Socket = StateData#state.socket,
Proceed = exmpp_xml:document_fragment_to_list( Proceed = exmpp_xml:document_fragment_to_list(
exmpp_server_tls:proceed(), ?DEFAULT_NS, ?PREFIXED_NS), exmpp_server_tls:proceed(), [?DEFAULT_NS], ?PREFIXED_NS),
TLSOpts = StateData#state.tls_options, TLSOpts = StateData#state.tls_options,
TLSSocket = (StateData#state.sockmod):starttls( TLSSocket = (StateData#state.sockmod):starttls(
Socket, TLSOpts, Socket, TLSOpts,
@ -388,7 +390,7 @@ stream_established({xmlstreamelement, El}, StateData) ->
% XXX No namespace conversion (:server <-> :client) is done. % XXX No namespace conversion (:server <-> :client) is done.
% This is handled by C2S and S2S send_element functions. % This is handled by C2S and S2S send_element functions.
ElOld = exmpp_xml:xmlel_to_xmlelement(El, ElOld = exmpp_xml:xmlel_to_xmlelement(El,
?DEFAULT_NS, ?PREFIXED_NS), [?DEFAULT_NS], ?PREFIXED_NS),
if if
(To /= error) and (From /= error) -> (To /= error) and (From /= error) ->
LFrom = From#jid.ldomain, LFrom = From#jid.ldomain,
@ -561,12 +563,12 @@ send_text(StateData, Text) ->
send_element(StateData, #xmlel{ns = ?NS_XMPP, name = 'stream'} = El) -> send_element(StateData, #xmlel{ns = ?NS_XMPP, name = 'stream'} = El) ->
send_text(StateData, exmpp_xml:document_to_list(El)); send_text(StateData, exmpp_stream:to_list(El));
send_element(StateData, #xmlel{ns = ?NS_JABBER_CLIENT} = El) -> send_element(StateData, #xmlel{ns = ?NS_JABBER_CLIENT} = El) ->
send_text(StateData, exmpp_xml:document_fragment_to_list(El, send_text(StateData, exmpp_stanza:to_list(El,
[?NS_JABBER_CLIENT], ?PREFIXED_NS)); ?NS_JABBER_CLIENT, ?PREFIXED_NS));
send_element(StateData, El) -> send_element(StateData, El) ->
send_text(StateData, exmpp_xml:document_fragment_to_list(El, send_text(StateData, exmpp_stanza:to_list(El,
?DEFAULT_NS, ?PREFIXED_NS)). ?DEFAULT_NS, ?PREFIXED_NS)).
@ -590,14 +592,14 @@ cancel_timer(Timer) ->
end. end.
is_key_packet(#xmlel{ns = ?NS_JABBER_DIALBACK, name = 'result', is_key_packet(#xmlel{ns = ?NS_DIALBACK, name = 'result',
attrs = Attrs} = El) -> attrs = Attrs} = El) ->
{key, {key,
exmpp_stanza:get_recipient_from_attrs(Attrs), exmpp_stanza:get_recipient_from_attrs(Attrs),
exmpp_stanza:get_sender_from_attrs(Attrs), exmpp_stanza:get_sender_from_attrs(Attrs),
exmpp_stanza:get_id_from_attrs(Attrs), exmpp_stanza:get_id_from_attrs(Attrs),
exmpp_xml:get_cdata_as_list(El)}; exmpp_xml:get_cdata_as_list(El)};
is_key_packet(#xmlel{ns = ?NS_JABBER_DIALBACK, name = 'verify', is_key_packet(#xmlel{ns = ?NS_DIALBACK, name = 'verify',
attrs = Attrs} = El) -> attrs = Attrs} = El) ->
{verify, {verify,
exmpp_stanza:get_recipient_from_attrs(Attrs), exmpp_stanza:get_recipient_from_attrs(Attrs),

View File

@ -101,8 +101,11 @@
% These are the namespace already declared by the stream opening. This is % These are the namespace already declared by the stream opening. This is
% used at serialization time. % used at serialization time.
-define(DEFAULT_NS, [?NS_JABBER_SERVER]). -define(DEFAULT_NS, ?NS_JABBER_SERVER).
-define(PREFIXED_NS, [{?NS_XMPP, "stream"}, {?NS_JABBER_DIALBACK, "db"}]). -define(PREFIXED_NS, [
{?NS_XMPP, ?NS_XMPP_pfx}, {?NS_DIALBACK, ?NS_DIALBACK_pfx}
]).
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% API %%% API
@ -263,7 +266,7 @@ open_socket1(Addr, Port) ->
wait_for_stream({xmlstreamstart, Opening}, StateData) -> wait_for_stream({xmlstreamstart, Opening}, StateData) ->
case {exmpp_stream:get_default_ns(Opening), case {exmpp_stream:get_default_ns(Opening),
exmpp_xml:is_ns_declared_here(Opening, ?NS_JABBER_DIALBACK), exmpp_xml:is_ns_declared_here(Opening, ?NS_DIALBACK),
exmpp_stream:get_version(Opening) == {1, 0}} of exmpp_stream:get_version(Opening) == {1, 0}} of
{?NS_JABBER_SERVER, true, false} -> {?NS_JABBER_SERVER, true, false} ->
send_db_request(StateData); send_db_request(StateData);
@ -786,12 +789,12 @@ send_text(StateData, Text) ->
ejabberd_socket:send(StateData#state.socket, Text). ejabberd_socket:send(StateData#state.socket, Text).
send_element(StateData, #xmlel{ns = ?NS_XMPP, name = 'stream'} = El) -> send_element(StateData, #xmlel{ns = ?NS_XMPP, name = 'stream'} = El) ->
send_text(StateData, exmpp_xml:document_to_list(El)); send_text(StateData, exmpp_stream:to_list(El));
send_element(StateData, #xmlel{ns = ?NS_JABBER_CLIENT} = El) -> send_element(StateData, #xmlel{ns = ?NS_JABBER_CLIENT} = El) ->
send_text(StateData, exmpp_xml:document_fragment_to_list(El, send_text(StateData, exmpp_stanza:to_list(El,
[?NS_JABBER_CLIENT], ?PREFIXED_NS)); ?NS_JABBER_CLIENT, ?PREFIXED_NS));
send_element(StateData, El) -> send_element(StateData, El) ->
send_text(StateData, exmpp_xml:document_fragment_to_list(El, send_text(StateData, exmpp_stanza:to_list(El,
?DEFAULT_NS, ?PREFIXED_NS)). ?DEFAULT_NS, ?PREFIXED_NS)).
send_queue(StateData, Q) -> send_queue(StateData, Q) ->
@ -888,14 +891,14 @@ send_db_request(StateData) ->
{next_state, wait_for_validation, StateData#state{new = New}, ?FSMTIMEOUT*6}. {next_state, wait_for_validation, StateData#state{new = New}, ?FSMTIMEOUT*6}.
is_verify_res(#xmlel{ns = ?NS_JABBER_DIALBACK, name = 'result', is_verify_res(#xmlel{ns = ?NS_DIALBACK, name = 'result',
attrs = Attrs}) -> attrs = Attrs}) ->
{result, {result,
exmpp_stanza:get_recipient_from_attrs(Attrs), exmpp_stanza:get_recipient_from_attrs(Attrs),
exmpp_stanza:get_sender_from_attrs(Attrs), exmpp_stanza:get_sender_from_attrs(Attrs),
exmpp_stanza:get_id_from_attrs(Attrs), exmpp_stanza:get_id_from_attrs(Attrs),
exmpp_stanza:get_type_from_attrs(Attrs)}; exmpp_stanza:get_type_from_attrs(Attrs)};
is_verify_res(#xmlel{ns = ?NS_JABBER_DIALBACK, name = 'verify', is_verify_res(#xmlel{ns = ?NS_DIALBACK, name = 'verify',
attrs = Attrs}) -> attrs = Attrs}) ->
{verify, {verify,
exmpp_stanza:get_recipient_from_attrs(Attrs), exmpp_stanza:get_recipient_from_attrs(Attrs),