25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-20 17:27:00 +01:00

Avoid generation of excessive records

This commit is contained in:
Evgeniy Khramtsov 2014-09-13 22:54:07 +04:00
parent c90786527e
commit 72fd353988
4 changed files with 52 additions and 180 deletions

View File

@ -1511,7 +1511,7 @@ client_state_master(Config) ->
Peer = ?config(slave, Config),
Presence = #presence{to = Peer},
Message = #message{to = Peer, thread = <<"1">>,
sub_els = [#chatstate_active{}]},
sub_els = [#chatstate{type = active}]},
wait_for_slave(Config),
%% Should be queued (but see below):
send(Config, Presence),
@ -1531,16 +1531,16 @@ client_state_master(Config) ->
client_state_slave(Config) ->
true = ?config(csi, Config),
Peer = ?config(master, Config),
send(Config, #csi_inactive{}),
send(Config, #csi{type = inactive}),
wait_for_master(Config),
#presence{from = Peer, sub_els = [#delay{}]} = recv(),
#message{from = Peer, thread = <<"1">>, sub_els = [#chatstate_active{}],
#message{from = Peer, thread = <<"1">>, sub_els = [#chatstate{type = active}],
body = [#text{data = <<"body">>}]} = recv(),
wait_for_master(Config),
send(Config, #csi_active{}),
send(Config, #csi{type = active}),
?recv2(#presence{from = Peer, type = unavailable, sub_els = [#delay{}]},
#message{from = Peer, thread = <<"1">>,
sub_els = [#chatstate_active{}]}),
sub_els = [#chatstate{type = active}]}),
disconnect(Config).
%%%===================================================================

View File

@ -1902,23 +1902,23 @@ encode({pubsub, _, _, _, _, _, _, _, _} = Pubsub) ->
encode({shim, _} = Headers) ->
encode_shim_headers(Headers,
[{<<"xmlns">>, <<"http://jabber.org/protocol/shim">>}]);
encode({chatstate_active} = Active) ->
encode({chatstate, active} = Active) ->
encode_chatstate_active(Active,
[{<<"xmlns">>,
<<"http://jabber.org/protocol/chatstates">>}]);
encode({chatstate_composing} = Composing) ->
encode({chatstate, composing} = Composing) ->
encode_chatstate_composing(Composing,
[{<<"xmlns">>,
<<"http://jabber.org/protocol/chatstates">>}]);
encode({chatstate_gone} = Gone) ->
encode({chatstate, gone} = Gone) ->
encode_chatstate_gone(Gone,
[{<<"xmlns">>,
<<"http://jabber.org/protocol/chatstates">>}]);
encode({chatstate_inactive} = Inactive) ->
encode({chatstate, inactive} = Inactive) ->
encode_chatstate_inactive(Inactive,
[{<<"xmlns">>,
<<"http://jabber.org/protocol/chatstates">>}]);
encode({chatstate_paused} = Paused) ->
encode({chatstate, paused} = Paused) ->
encode_chatstate_paused(Paused,
[{<<"xmlns">>,
<<"http://jabber.org/protocol/chatstates">>}]);
@ -1994,10 +1994,10 @@ encode({carbons_sent, _} = Sent) ->
[{<<"xmlns">>, <<"urn:xmpp:carbons:2">>}]);
encode({feature_csi, _} = Csi) ->
encode_feature_csi(Csi, []);
encode({csi_active} = Active) ->
encode({csi, active} = Active) ->
encode_csi_active(Active,
[{<<"xmlns">>, <<"urn:xmpp:csi:0">>}]);
encode({csi_inactive} = Inactive) ->
encode({csi, inactive} = Inactive) ->
encode_csi_inactive(Inactive,
[{<<"xmlns">>, <<"urn:xmpp:csi:0">>}]);
encode({feature_sm, _} = Sm) ->
@ -2158,15 +2158,15 @@ get_ns({pubsub, _, _, _, _, _, _, _, _}) ->
<<"http://jabber.org/protocol/pubsub">>;
get_ns({shim, _}) ->
<<"http://jabber.org/protocol/shim">>;
get_ns({chatstate_active}) ->
get_ns({chatstate, active}) ->
<<"http://jabber.org/protocol/chatstates">>;
get_ns({chatstate_composing}) ->
get_ns({chatstate, composing}) ->
<<"http://jabber.org/protocol/chatstates">>;
get_ns({chatstate_gone}) ->
get_ns({chatstate, gone}) ->
<<"http://jabber.org/protocol/chatstates">>;
get_ns({chatstate_inactive}) ->
get_ns({chatstate, inactive}) ->
<<"http://jabber.org/protocol/chatstates">>;
get_ns({chatstate_paused}) ->
get_ns({chatstate, paused}) ->
<<"http://jabber.org/protocol/chatstates">>;
get_ns({delay, _, _}) -> <<"urn:xmpp:delay">>;
get_ns({legacy_delay, _, _}) -> <<"jabber:x:delay">>;
@ -2200,8 +2200,8 @@ get_ns({carbons_received, _}) ->
<<"urn:xmpp:carbons:2">>;
get_ns({carbons_sent, _}) -> <<"urn:xmpp:carbons:2">>;
get_ns({feature_csi, _}) -> <<"urn:xmpp:csi:0">>;
get_ns({csi_active}) -> <<"urn:xmpp:csi:0">>;
get_ns({csi_inactive}) -> <<"urn:xmpp:csi:0">>;
get_ns({csi, active}) -> <<"urn:xmpp:csi:0">>;
get_ns({csi, inactive}) -> <<"urn:xmpp:csi:0">>;
get_ns(_) -> <<>>.
dec_int(Val) -> dec_int(Val, infinity, infinity).
@ -2359,11 +2359,7 @@ pp(pubsub, 8) ->
[subscriptions, affiliations, publish, subscribe,
unsubscribe, options, items, retract];
pp(shim, 1) -> [headers];
pp(chatstate_active, 0) -> [];
pp(chatstate_composing, 0) -> [];
pp(chatstate_gone, 0) -> [];
pp(chatstate_inactive, 0) -> [];
pp(chatstate_paused, 0) -> [];
pp(chatstate, 1) -> [type];
pp(delay, 2) -> [stamp, from];
pp(legacy_delay, 2) -> [stamp, from];
pp(streamhost, 3) -> [jid, host, port];
@ -2391,8 +2387,7 @@ pp(carbons_private, 0) -> [];
pp(carbons_received, 1) -> [forwarded];
pp(carbons_sent, 1) -> [forwarded];
pp(feature_csi, 1) -> [xmlns];
pp(csi_active, 0) -> [];
pp(csi_inactive, 0) -> [];
pp(csi, 1) -> [type];
pp(feature_sm, 1) -> [xmlns];
pp(sm_enable, 3) -> [max, resume, xmlns];
pp(sm_enabled, 5) -> [id, location, max, resume, xmlns];
@ -3365,18 +3360,18 @@ encode_feature_sm_attr_xmlns(_val, _acc) ->
decode_csi_inactive(__TopXMLNS, __IgnoreEls,
{xmlel, <<"inactive">>, _attrs, _els}) ->
{csi_inactive}.
{csi, inactive}.
encode_csi_inactive({csi_inactive}, _xmlns_attrs) ->
encode_csi_inactive({csi, inactive}, _xmlns_attrs) ->
_els = [],
_attrs = _xmlns_attrs,
{xmlel, <<"inactive">>, _attrs, _els}.
decode_csi_active(__TopXMLNS, __IgnoreEls,
{xmlel, <<"active">>, _attrs, _els}) ->
{csi_active}.
{csi, active}.
encode_csi_active({csi_active}, _xmlns_attrs) ->
encode_csi_active({csi, active}, _xmlns_attrs) ->
_els = [],
_attrs = _xmlns_attrs,
{xmlel, <<"active">>, _attrs, _els}.
@ -5500,9 +5495,9 @@ encode_delay_attr_from(_val, _acc) ->
decode_chatstate_paused(__TopXMLNS, __IgnoreEls,
{xmlel, <<"paused">>, _attrs, _els}) ->
{chatstate_paused}.
{chatstate, paused}.
encode_chatstate_paused({chatstate_paused},
encode_chatstate_paused({chatstate, paused},
_xmlns_attrs) ->
_els = [],
_attrs = _xmlns_attrs,
@ -5510,9 +5505,9 @@ encode_chatstate_paused({chatstate_paused},
decode_chatstate_inactive(__TopXMLNS, __IgnoreEls,
{xmlel, <<"inactive">>, _attrs, _els}) ->
{chatstate_inactive}.
{chatstate, inactive}.
encode_chatstate_inactive({chatstate_inactive},
encode_chatstate_inactive({chatstate, inactive},
_xmlns_attrs) ->
_els = [],
_attrs = _xmlns_attrs,
@ -5520,18 +5515,19 @@ encode_chatstate_inactive({chatstate_inactive},
decode_chatstate_gone(__TopXMLNS, __IgnoreEls,
{xmlel, <<"gone">>, _attrs, _els}) ->
{chatstate_gone}.
{chatstate, gone}.
encode_chatstate_gone({chatstate_gone}, _xmlns_attrs) ->
encode_chatstate_gone({chatstate, gone},
_xmlns_attrs) ->
_els = [],
_attrs = _xmlns_attrs,
{xmlel, <<"gone">>, _attrs, _els}.
decode_chatstate_composing(__TopXMLNS, __IgnoreEls,
{xmlel, <<"composing">>, _attrs, _els}) ->
{chatstate_composing}.
{chatstate, composing}.
encode_chatstate_composing({chatstate_composing},
encode_chatstate_composing({chatstate, composing},
_xmlns_attrs) ->
_els = [],
_attrs = _xmlns_attrs,
@ -5539,9 +5535,9 @@ encode_chatstate_composing({chatstate_composing},
decode_chatstate_active(__TopXMLNS, __IgnoreEls,
{xmlel, <<"active">>, _attrs, _els}) ->
{chatstate_active}.
{chatstate, active}.
encode_chatstate_active({chatstate_active},
encode_chatstate_active({chatstate, active},
_xmlns_attrs) ->
_els = [],
_attrs = _xmlns_attrs,

View File

@ -1,6 +1,10 @@
%% Created automatically by XML generator (xml_gen.erl)
%% Source: xmpp_codec.spec
-record(chatstate, {type :: active | composing | gone | inactive | paused}).
-record(csi, {type :: active | inactive}).
-record(feature_register, {}).
-record(sasl_success, {text :: any()}).
@ -8,8 +12,6 @@
-record(text, {lang :: binary(),
data :: binary()}).
-record(chatstate_paused, {}).
-record(streamhost, {jid :: any(),
host :: binary(),
port = 1080 :: non_neg_integer()}).
@ -26,8 +28,6 @@
jid :: any(),
subid :: binary()}).
-record(csi_inactive, {}).
-record(ping, {}).
-record(delay, {stamp :: any(),
@ -61,8 +61,6 @@
resume = false :: any(),
xmlns :: binary()}).
-record(chatstate_gone, {}).
-record(starttls_failure, {}).
-record(sasl_challenge, {text :: any()}).
@ -129,13 +127,9 @@
-record(sasl_response, {text :: any()}).
-record(chatstate_inactive, {}).
-record(pubsub_subscribe, {node :: binary(),
jid :: any()}).
-record(chatstate_composing, {}).
-record(sasl_auth, {mechanism :: binary(),
text :: any()}).
@ -232,8 +226,6 @@
-record(block_list, {}).
-record(csi_active, {}).
-record(xdata_field, {label :: binary(),
type :: 'boolean' | 'fixed' | 'hidden' | 'jid-multi' | 'jid-single' | 'list-multi' | 'list-single' | 'text-multi' | 'text-private' | 'text-single',
var :: binary(),
@ -269,8 +261,6 @@
mode = tcp :: 'tcp' | 'udp',
sid :: binary()}).
-record(chatstate_active, {}).
-record(vcard_org, {name :: binary(),
units = [] :: [binary()]}).
@ -491,122 +481,4 @@
-record(time, {tzo :: any(),
utc :: any()}).
-type xmpp_codec_type() :: #session{} |
#compression{} |
#pubsub_subscription{} |
#version{} |
#pubsub_affiliation{} |
#muc_admin{} |
#sm_a{} |
#carbons_sent{} |
#p1_rebind{} |
#sasl_abort{} |
#carbons_received{} |
#pubsub_retract{} |
#compressed{} |
#block_list{} |
#'see-other-host'{} |
#starttls_proceed{} |
#sm_resumed{} |
#forwarded{} |
#privacy_list{} |
#text{} |
#vcard_org{} |
#feature_sm{} |
#pubsub_item{} |
#roster_item{} |
#pubsub_event_item{} |
#muc_item{} |
#shim{} |
#pubsub_event_items{} |
#disco_items{} |
#pubsub_options{} |
#sasl_success{} |
#compress{} |
#bytestreams{} |
#vcard_key{} |
#identity{} |
#feature_csi{} |
#legacy_delay{} |
#muc_user_destroy{} |
#muc_owner_destroy{} |
#privacy{} |
#delay{} |
#muc_history{} |
#bookmark_url{} |
#vcard_email{} |
#vcard_label{} |
#vcard_tel{} |
#vcard_logo{} |
#disco_info{} |
#vcard_geo{} |
#vcard_photo{} |
#muc_owner{} |
#pubsub{} |
#sm_r{} |
#muc_actor{} |
#error{} |
#stream_error{} |
#feature_register{} |
#roster{} |
#muc_user{} |
#vcard_adr{} |
#register{} |
#csi_active{} |
#muc_invite{} |
#carbons_disable{} |
#chatstate_active{} |
#bookmark_conference{} |
#time{} |
#sasl_response{} |
#chatstate_inactive{} |
#pubsub_subscribe{} |
#presence{} |
#message{} |
#sm_enable{} |
#chatstate_gone{} |
#starttls_failure{} |
#sasl_challenge{} |
#gone{} |
#private{} |
#compress_failure{} |
#sasl_failure{} |
#bookmark_storage{} |
#vcard_name{} |
#sm_resume{} |
#carbons_enable{} |
#carbons_private{} |
#pubsub_unsubscribe{} |
#csi_inactive{} |
#muc_decline{} |
#sasl_auth{} |
#p1_push{} |
#pubsub_publish{} |
#unblock{} |
#p1_ack{} |
#block{} |
#xdata{} |
#iq{} |
#last{} |
#redirect{} |
#sm_enabled{} |
#pubsub_event{} |
#vcard_sound{} |
#chatstate_paused{} |
#streamhost{} |
#stat{} |
#xdata_field{} |
#bind{} |
#sm_failed{} |
#vcard{} |
#chatstate_composing{} |
#ping{} |
#disco_item{} |
#privacy_item{} |
#caps{} |
#muc{} |
#stream_features{} |
#stats{} |
#pubsub_items{} |
#starttls{} |
#sasl_mechanisms{}.

View File

@ -1757,30 +1757,32 @@
result = {shim, '$headers'},
refs = [#ref{name = shim_header, label = '$headers'}]}).
-record(chatstate, {type :: active | composing | gone | inactive | paused}).
-xml(chatstate_active,
#elem{name = <<"active">>,
xmlns = <<"http://jabber.org/protocol/chatstates">>,
result = {chatstate_active}}).
result = {chatstate, active}}).
-xml(chatstate_composing,
#elem{name = <<"composing">>,
xmlns = <<"http://jabber.org/protocol/chatstates">>,
result = {chatstate_composing}}).
result = {chatstate, composing}}).
-xml(chatstate_gone,
#elem{name = <<"gone">>,
xmlns = <<"http://jabber.org/protocol/chatstates">>,
result = {chatstate_gone}}).
result = {chatstate, gone}}).
-xml(chatstate_inactive,
#elem{name = <<"inactive">>,
xmlns = <<"http://jabber.org/protocol/chatstates">>,
result = {chatstate_inactive}}).
result = {chatstate, inactive}}).
-xml(chatstate_paused,
#elem{name = <<"paused">>,
xmlns = <<"http://jabber.org/protocol/chatstates">>,
result = {chatstate_paused}}).
result = {chatstate, paused}}).
-xml(delay,
#elem{name = <<"delay">>,
@ -2101,15 +2103,17 @@
result = {feature_csi, '$xmlns'},
attrs = [#attr{name = <<"xmlns">>}]}).
-record(csi, {type :: active | inactive}).
-xml(csi_active,
#elem{name = <<"active">>,
xmlns = <<"urn:xmpp:csi:0">>,
result = {csi_active}}).
result = {csi, active}}).
-xml(csi_inactive,
#elem{name = <<"inactive">>,
xmlns = <<"urn:xmpp:csi:0">>,
result = {csi_inactive}}).
result = {csi, inactive}}).
-xml(feature_sm,
#elem{name = <<"sm">>,