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

Do not use the #iq record anymore internally. However it's still created

and passed to other modules.

SVN Revision: 1405
This commit is contained in:
Jean-Sébastien Pédron 2008-07-01 14:25:02 +00:00
parent 5317dd64d7
commit 48cf5cb84a
5 changed files with 31 additions and 55 deletions

View File

@ -39,6 +39,10 @@
* src/ejabberd_router.erl: Change warning message. * src/ejabberd_router.erl: Change warning message.
* src/ejabberd_sm.erl, src/ejabberd_c2s.erl, src/ejabberd_local.erl,
src/gen_iq_handler.erl: Do not use the #iq record anymore internally.
However it's still created and passed to other modules.
2008-06-30 Jean-Sébastien Pédron <js.pedron@meetic-corp.com> 2008-06-30 Jean-Sébastien Pédron <js.pedron@meetic-corp.com>
* src/Makefile.in: Remove the -I flag for exmpp includes; the * src/Makefile.in: Remove the -I flag for exmpp includes; the

View File

@ -124,13 +124,6 @@
[?NS_JABBER_CLIENT], [{?NS_XMPP, "stream"}])). [?NS_JABBER_CLIENT], [{?NS_XMPP, "stream"}])).
-define(ERR_FEATURE_NOT_IMPLEMENTED, ?STANZA_ERROR('feature-not-implemented')). -define(ERR_FEATURE_NOT_IMPLEMENTED, ?STANZA_ERROR('feature-not-implemented')).
% XXX OLD FORMAT: Re-include jlib.hrl (after clean-up).
-record(iq, {id = "",
type,
xmlns = "",
lang = "",
sub_el}).
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% API %%% API
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
@ -546,7 +539,7 @@ wait_for_feature_request({xmlstreamelement, #xmlel{ns = NS, name = Name} = El},
certfile, 1, StateData#state.tls_options)] certfile, 1, StateData#state.tls_options)]
end, end,
Socket = StateData#state.socket, Socket = StateData#state.socket,
Proceed = exmpp_xml:document_fragment_to_list( Proceed = exmpp_xml:node_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,
@ -1825,10 +1818,8 @@ update_priority(Priority, Packet, StateData) ->
process_privacy_iq(From, To, process_privacy_iq(From, To,
El, El,
StateData) -> StateData) ->
% XXX OLD FORMAT: IQ is #iq. % XXX OLD FORMAT: IQ_Rec is an #iq.
ElOld = exmpp_xml:xmlel_to_xmlelement(El, IQ_Rec = jlib:iq_query_info(El),
[?DEFAULT_NS], ?PREFIXED_NS),
IQOld = jlib:iq_query_info(ElOld),
% XXX OLD FORMAT: JIDs. % XXX OLD FORMAT: JIDs.
FromOld = jlib:to_old_jid(From), FromOld = jlib:to_old_jid(From),
ToOld = jlib:to_old_jid(To), ToOld = jlib:to_old_jid(To),
@ -1838,13 +1829,13 @@ process_privacy_iq(From, To,
R = ejabberd_hooks:run_fold( R = ejabberd_hooks:run_fold(
privacy_iq_get, StateData#state.server, privacy_iq_get, StateData#state.server,
{error, ?ERR_FEATURE_NOT_IMPLEMENTED}, {error, ?ERR_FEATURE_NOT_IMPLEMENTED},
[FromOld, ToOld, IQOld, StateData#state.privacy_list]), [FromOld, ToOld, IQ_Rec, StateData#state.privacy_list]),
{R, StateData}; {R, StateData};
set -> set ->
case ejabberd_hooks:run_fold( case ejabberd_hooks:run_fold(
privacy_iq_set, StateData#state.server, privacy_iq_set, StateData#state.server,
{error, ?ERR_FEATURE_NOT_IMPLEMENTED}, {error, ?ERR_FEATURE_NOT_IMPLEMENTED},
[FromOld, ToOld, IQOld]) of [FromOld, ToOld, IQ_Rec]) of
{result, R, NewPrivList} -> {result, R, NewPrivList} ->
{{result, R}, {{result, R},
StateData#state{privacy_list = NewPrivList}}; StateData#state{privacy_list = NewPrivList}};
@ -1930,13 +1921,14 @@ resend_subscription_requests(#state{user = User,
PendingSubscriptions). PendingSubscriptions).
process_unauthenticated_stanza(StateData, El) -> process_unauthenticated_stanza(StateData, El) ->
ElOld = exmpp_xml:xmlel_to_xmlelement(El, [?DEFAULT_NS], ?PREFIXED_NS), case exmpp_iq:get_kind(El) of
case jlib:iq_query_info(ElOld) of request ->
IQ when is_record(IQ, iq) -> % XXX OLD FORMAT: IQ_Rec is an #iq.
IQ_Rec = jlib:iq_query_info(El),
ResOld = ejabberd_hooks:run_fold(c2s_unauthenticated_iq, ResOld = ejabberd_hooks:run_fold(c2s_unauthenticated_iq,
StateData#state.server, StateData#state.server,
empty, empty,
[StateData#state.server, IQ, [StateData#state.server, IQ_Rec,
StateData#state.ip]), StateData#state.ip]),
case ResOld of case ResOld of
empty -> empty ->

View File

@ -77,18 +77,14 @@ process_iq(From, To, Packet) ->
request -> request ->
Host = To#jid.ldomain, Host = To#jid.ldomain,
Request = exmpp_iq:get_request(Packet), Request = exmpp_iq:get_request(Packet),
XMLNS = case Request#xmlel.ns of XMLNS = exmpp_xml:get_ns_as_list(Request),
NS when is_atom(NS) -> atom_to_list(NS);
NS -> NS
end,
case ets:lookup(?IQTABLE, {XMLNS, Host}) of case ets:lookup(?IQTABLE, {XMLNS, Host}) of
[{_, Module, Function}] -> [{_, Module, Function}] ->
% XXX OLD FORMAT: From, To, Packet. % XXX OLD FORMAT: From, To.
FromOld = jlib:to_old_jid(From), FromOld = jlib:to_old_jid(From),
ToOld = jlib:to_old_jid(To), ToOld = jlib:to_old_jid(To),
PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet, % XXX OLD FORMAT: IQ_Rec is an #iq.
[?DEFAULT_NS], ?PREFIXED_NS), IQ_Rec = jlib:iq_query_info(Packet),
IQ_Rec = jlib:iq_query_info(PacketOld),
ResIQ = Module:Function(FromOld, ToOld, IQ_Rec), ResIQ = Module:Function(FromOld, ToOld, IQ_Rec),
if if
ResIQ /= ignore -> ResIQ /= ignore ->

View File

@ -74,13 +74,6 @@
{?NS_XMPP, ?NS_XMPP_pfx}, {?NS_DIALBACK, ?NS_DIALBACK_pfx} {?NS_XMPP, ?NS_XMPP_pfx}, {?NS_DIALBACK, ?NS_DIALBACK_pfx}
]). ]).
% XXX OLD FORMAT: Re-include jlib.hrl (after clean-up).
-record(iq, {id = "",
type,
xmlns = "",
lang = "",
sub_el}).
%%==================================================================== %%====================================================================
%% API %% API
%%==================================================================== %%====================================================================
@ -662,19 +655,19 @@ get_max_user_sessions(LUser, Host) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
process_iq(From, To, Packet) -> process_iq(From, To, Packet) ->
% XXX OLD FORMAT: From, To, Packet. case exmpp_iq:get_kind(Packet) of
FromOld = jlib:to_old_jid(From), request ->
ToOld = jlib:to_old_jid(To),
PacketOld = exmpp_xml:xmlel_to_xmlelement(Packet,
[?DEFAULT_NS], ?PREFIXED_NS),
IQ = jlib:iq_query_info(PacketOld),
case IQ of
#iq{xmlns = XMLNS} ->
Host = To#jid.ldomain, Host = To#jid.ldomain,
Request = exmpp_iq:get_request(Packet),
XMLNS = exmpp_xml:get_ns_as_list(Request),
case ets:lookup(sm_iqtable, {XMLNS, Host}) of case ets:lookup(sm_iqtable, {XMLNS, Host}) of
[{_, Module, Function}] -> [{_, Module, Function}] ->
% XXX OLD FORMAT: From, To, IQ. % XXX OLD FORMAT: From, To.
ResIQ = Module:Function(FromOld, ToOld, IQ), FromOld = jlib:to_old_jid(From),
ToOld = jlib:to_old_jid(To),
% XXX OLD FORMAT: IQ_Rec is an #iq.
IQ_Rec = jlib:iq_query_info(Packet),
ResIQ = Module:Function(FromOld, ToOld, IQ_Rec),
if if
ResIQ /= ignore -> ResIQ /= ignore ->
% XXX OLD FORMAT: ResIQ. % XXX OLD FORMAT: ResIQ.
@ -686,14 +679,13 @@ process_iq(From, To, Packet) ->
ok ok
end; end;
[{_, Module, Function, Opts}] -> [{_, Module, Function, Opts}] ->
% XXX OLD FORMAT: From, To, IQ.
gen_iq_handler:handle(Host, Module, Function, Opts, gen_iq_handler:handle(Host, Module, Function, Opts,
From, To, Packet); From, To, Packet);
[] -> [] ->
Err = exmpp_iq:error(Packet, 'service-unavailable'), Err = exmpp_iq:error(Packet, 'service-unavailable'),
ejabberd_router:route(To, From, Err) ejabberd_router:route(To, From, Err)
end; end;
reply -> response ->
ok; ok;
_ -> _ ->
Err = exmpp_iq:error(Packet, 'bad-request'), Err = exmpp_iq:error(Packet, 'bad-request'),

View File

@ -227,14 +227,6 @@ convert_to_old_structs(From, To, IQ) ->
true -> true ->
F = jlib:to_old_jid(From), F = jlib:to_old_jid(From),
T = jlib:to_old_jid(To), T = jlib:to_old_jid(To),
Default_NS = case lists:member({IQ#xmlel.ns, none}, I_Rec = jlib:iq_query_info(IQ),
IQ#xmlel.declared_ns) of {F, T, I_Rec}
true -> [];
false -> [IQ#xmlel.ns]
end,
IQOld = exmpp_xml:xmlel_to_xmlelement(IQ,
Default_NS,
[{?NS_XMPP, ?NS_XMPP_pfx}, {?NS_DIALBACK, ?NS_DIALBACK_pfx}]),
I = jlib:iq_query_info(IQOld),
{F, T, I}
end. end.