diff --git a/mod_log_chat/src/mod_log_chat.erl b/mod_log_chat/src/mod_log_chat.erl index 83fb4f5..f56fc05 100644 --- a/mod_log_chat/src/mod_log_chat.erl +++ b/mod_log_chat/src/mod_log_chat.erl @@ -13,8 +13,8 @@ -export([start/2, init/1, stop/1, - log_packet_send/3, - log_packet_receive/4]). + log_packet_send/4, + log_packet_receive/5]). -ifndef(LAGER). -define(LAGER, 1). @@ -77,13 +77,15 @@ stop(Host) -> gen_mod:get_module_proc(Host, ?PROCNAME) ! stop, ok. -log_packet_send(From, To, Packet) -> - log_packet(From, To, Packet, From#jid.lserver). +log_packet_send(Packet, _C2SState, From, To) -> + log_packet(From, To, Packet, From#jid.lserver), + Packet. -log_packet_receive(_JID, From, To, _Packet) when From#jid.lserver == To#jid.lserver-> - ok; % only log at send time if the message is local to the server -log_packet_receive(_JID, From, To, Packet) -> - log_packet(From, To, Packet, To#jid.lserver). +log_packet_receive(Packet, _C2SState, _JID, From, To) when From#jid.lserver == To#jid.lserver-> + Packet; % only log at send time if the message is local to the server +log_packet_receive(Packet, _C2SState, _JID, From, To) -> + log_packet(From, To, Packet, To#jid.lserver), + Packet. log_packet(From, To, Packet = #xmlel{name = <<"message">>, attrs = Attrs}, Host) -> case xml:get_attr_s(<<"type">>, Attrs) of diff --git a/mod_logxml/src/mod_logxml.erl b/mod_logxml/src/mod_logxml.erl index 53f5f8c..ac822c1 100644 --- a/mod_logxml/src/mod_logxml.erl +++ b/mod_logxml/src/mod_logxml.erl @@ -12,7 +12,7 @@ -behaviour(gen_mod). -export([start/2, init/7, stop/1, - send_packet/3, receive_packet/4]). + send_packet/4, receive_packet/5]). -include("ejabberd.hrl"). -include("jlib.hrl"). @@ -166,15 +166,17 @@ loop(Host, IoDevice, Filename, Logdir, CheckRKP, RotateO, PacketC, Gregorian_day, Timezone, ShowIP, FilterO) end. -send_packet(FromJID, ToJID, P) -> +send_packet(P, _C2SState, FromJID, ToJID) -> Host = FromJID#jid.lserver, Proc = gen_mod:get_module_proc(Host, ?PROCNAME), - Proc ! {addlog, {send, FromJID, ToJID, P}}. + Proc ! {addlog, {send, FromJID, ToJID, P}}, + P. -receive_packet(_JID, From, To, P) -> +receive_packet(P, _C2SState, _JID, From, To) -> Host = To#jid.lserver, Proc = gen_mod:get_module_proc(Host, ?PROCNAME), - Proc ! {addlog, {recv, From, To, P}}. + Proc ! {addlog, {recv, From, To, P}}, + P. add_log(Io, Timezone, ShowIP, {Orientation, From, To, Packet}, _OSD) -> %%{Orientation, Stanza, Direction} = OSD, diff --git a/mod_mam_mnesia/src/mod_mam_mnesia.erl b/mod_mam_mnesia/src/mod_mam_mnesia.erl index 78a1683..bccfdb8 100644 --- a/mod_mam_mnesia/src/mod_mam_mnesia.erl +++ b/mod_mam_mnesia/src/mod_mam_mnesia.erl @@ -51,8 +51,8 @@ %% ejabberd_hooks callbacks. -export([disco_features/5, - receive_stanza/4, - send_stanza/3, + receive_stanza/5, + send_stanza/4, remove_user/2]). %% gen_iq_handler callback. @@ -274,10 +274,10 @@ disco_features({result, OtherFeatures}, {result, OtherFeatures ++ [?NS_MAM]}; disco_features(Acc, _From, _To, _Node, _Lang) -> Acc. --spec receive_stanza(jid(), jid(), jid(), xmlel()) -> ok. +-spec receive_stanza(xmlel(), term(), jid(), jid(), jid()) -> xmlel(). -receive_stanza(#jid{luser = U, lserver = S} = JID, From, To, - #xmlel{name = <<"message">>} = Stanza) -> +receive_stanza(#xmlel{name = <<"message">>} = Stanza, _C2SState, + #jid{luser = U, lserver = S} = JID, From, To) -> case is_desired(incoming, JID, To, Stanza) of true -> Proc = gen_mod:get_module_proc(S, ?PROCNAME), @@ -288,15 +288,15 @@ receive_stanza(#jid{luser = U, lserver = S} = JID, From, To, ?GEN_SERVER:cast(Proc, {store, {U, S}, Msg}); false -> ?DEBUG("Won't archive undesired incoming stanza for ~s", - [jlib:jid_to_string(To)]), - ok - end; -receive_stanza(_JID, _From, _To, _Stanza) -> ok. + [jlib:jid_to_string(To)]) + end, + Stanza; +receive_stanza(Stanza, _C2SState, _JID, _From, _To) -> Stanza. --spec send_stanza(jid(), jid(), xmlel()) -> ok. +-spec send_stanza(xmlel(), term(), jid(), jid()) -> xmlel(). -send_stanza(#jid{luser = U, lserver = S} = From, To, - #xmlel{name = <<"message">>} = Stanza) -> +send_stanza(#xmlel{name = <<"message">>} = Stanza, _C2SState, + #jid{luser = U, lserver = S} = From, To) -> case is_desired(outgoing, From, To, Stanza) of true -> Proc = gen_mod:get_module_proc(S, ?PROCNAME), @@ -307,10 +307,10 @@ send_stanza(#jid{luser = U, lserver = S} = From, To, ?GEN_SERVER:cast(Proc, {store, {U, S}, Msg}); false -> ?DEBUG("Won't archive undesired outgoing stanza from ~s", - [jlib:jid_to_string(From)]), - ok - end; -send_stanza(_From, _To, _Stanza) -> ok. + [jlib:jid_to_string(From)]) + end, + Stanza; +send_stanza(Stanza, _C2SState, _From, _To) -> Stanza. %%-------------------------------------------------------------------- %% Check whether stanza should be stored. diff --git a/mod_message_log/src/mod_message_log.erl b/mod_message_log/src/mod_message_log.erl index 5e1492c..47f1762 100644 --- a/mod_message_log/src/mod_message_log.erl +++ b/mod_message_log/src/mod_message_log.erl @@ -25,8 +25,8 @@ code_change/3]). %% ejabberd_hooks callbacks. --export([log_packet_send/3, - log_packet_receive/4, +-export([log_packet_send/4, + log_packet_receive/5, log_packet_offline/3, reopen_log/0]). @@ -140,15 +140,17 @@ code_change(_OldVsn, State, _Extra) -> %% ejabberd_hooks callbacks. %% ------------------------------------------------------------------- --spec log_packet_send(jid(), jid(), xmlel()) -> any(). +-spec log_packet_send(xmlel(), term(), jid(), jid()) -> xmlel(). -log_packet_send(From, To, Packet) -> - log_packet(outgoing, From, To, Packet). +log_packet_send(Packet, _C2SState, From, To) -> + log_packet(outgoing, From, To, Packet), + Packet. --spec log_packet_receive(jid(), jid(), jid(), xmlel()) -> any(). +-spec log_packet_receive(xmlel(), term(), jid(), jid(), jid()) -> xmlel(). -log_packet_receive(JID, From, _To, Packet) -> - log_packet(incoming, From, JID, Packet). +log_packet_receive(Packet, _C2SState, JID, From, _To) -> + log_packet(incoming, From, JID, Packet), + Packet. -spec log_packet_offline(jid(), jid(), xmlel()) -> any(). diff --git a/mod_post_log/src/mod_post_log.erl b/mod_post_log/src/mod_post_log.erl index 571116d..65af872 100644 --- a/mod_post_log/src/mod_post_log.erl +++ b/mod_post_log/src/mod_post_log.erl @@ -14,7 +14,7 @@ -export([start/2, stop/1, - log_user_send/3, + log_user_send/4, post_result/1]). -include("ejabberd.hrl"). @@ -36,8 +36,9 @@ stop(Host) -> ?MODULE, log_user_send, 50), ok. -log_user_send(From, To, Packet) -> - ok = log_packet(From, To, Packet). +log_user_send(Packet, _C2SState, From, To) -> + ok = log_packet(From, To, Packet), + Packet. log_packet(From, To, #xmlel{name = <<"message">>} = Packet) -> ok = log_message(From, To, Packet); diff --git a/mod_statsdx/src/mod_statsdx.erl b/mod_statsdx/src/mod_statsdx.erl index fea3b08..5abf1de 100644 --- a/mod_statsdx/src/mod_statsdx.erl +++ b/mod_statsdx/src/mod_statsdx.erl @@ -22,8 +22,8 @@ web_menu_node/3, web_page_node/5, web_menu_host/3, web_page_host/3, %% Hooks - register_user/2, remove_user/2, user_send_packet/3, - user_send_packet_traffic/3, user_receive_packet_traffic/4, + register_user/2, remove_user/2, user_send_packet/4, + user_send_packet_traffic/4, user_receive_packet_traffic/5, user_login/1, user_logout/4, user_logout_sm/3]). -include("ejabberd.hrl"). @@ -224,14 +224,15 @@ remove_user(_User, Host) -> ets:update_counter(TableHost, {remove_user, Host}, 1), ets:update_counter(TableServer, {remove_user, server}, 1). -user_send_packet(FromJID, ToJID, NewEl) -> +user_send_packet(NewEl, _C2SState, FromJID, ToJID) -> %% Registrarse para tramitar Host/mod_stats2file case catch binary_to_existing_atom(ToJID#jid.lresource, utf8) of ?MODULE -> received_response(FromJID, ToJID, NewEl); _ -> ok - end. + end, + NewEl. -user_send_packet_traffic(FromJID, ToJID, NewEl) -> +user_send_packet_traffic(NewEl, _C2SState, FromJID, ToJID) -> %% Only required for traffic stats Host = FromJID#jid.lserver, HostTo = ToJID#jid.lserver, @@ -246,10 +247,11 @@ user_send_packet_traffic(FromJID, ToJID, NewEl) -> false -> out end, Table = table_name(Host), - ets:update_counter(Table, {send, Host, Type2, Dest}, 1). + ets:update_counter(Table, {send, Host, Type2, Dest}, 1), + NewEl. %% Only required for traffic stats -user_receive_packet_traffic(_JID, From, To, FixedPacket) -> +user_receive_packet_traffic(FixedPacket, _C2SState, _JID, From, To) -> HostFrom = From#jid.lserver, Host = To#jid.lserver, {xmlel, Type, _, _} = FixedPacket, @@ -263,7 +265,8 @@ user_receive_packet_traffic(_JID, From, To, FixedPacket) -> false -> out end, Table = table_name(Host), - ets:update_counter(Table, {recv, Host, Type2, Dest}, 1). + ets:update_counter(Table, {recv, Host, Type2, Dest}, 1), + FixedPacket. %%%==================================