]> granicus.if.org Git - ejabberd/commitdiff
Avoid generation of excessive records
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sat, 13 Sep 2014 18:54:07 +0000 (22:54 +0400)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Sat, 13 Sep 2014 18:54:07 +0000 (22:54 +0400)
test/ejabberd_SUITE.erl
tools/xmpp_codec.erl
tools/xmpp_codec.hrl
tools/xmpp_codec.spec

index 0cc5afec3dc0db659605eff3fb672b19386d00bc..471265c59fe447ae9ffc7ee579deeee36a5c285f 100644 (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).
 
 %%%===================================================================
index d106fa8f408bed6bcc7ce01bde153f8f89c9b4e0..58749af285c09281234f559778b730470dc69edb 100644 (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({chatstateactive} = Active) ->
     encode_chatstate_active(Active,
                            [{<<"xmlns">>,
                              <<"http://jabber.org/protocol/chatstates">>}]);
-encode({chatstate_composing} = Composing) ->
+encode({chatstatecomposing} = Composing) ->
     encode_chatstate_composing(Composing,
                               [{<<"xmlns">>,
                                 <<"http://jabber.org/protocol/chatstates">>}]);
-encode({chatstate_gone} = Gone) ->
+encode({chatstategone} = Gone) ->
     encode_chatstate_gone(Gone,
                          [{<<"xmlns">>,
                            <<"http://jabber.org/protocol/chatstates">>}]);
-encode({chatstate_inactive} = Inactive) ->
+encode({chatstateinactive} = Inactive) ->
     encode_chatstate_inactive(Inactive,
                              [{<<"xmlns">>,
                                <<"http://jabber.org/protocol/chatstates">>}]);
-encode({chatstate_paused} = Paused) ->
+encode({chatstatepaused} = 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({csiactive} = Active) ->
     encode_csi_active(Active,
                      [{<<"xmlns">>, <<"urn:xmpp:csi:0">>}]);
-encode({csi_inactive} = Inactive) ->
+encode({csiinactive} = 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({chatstateactive}) ->
     <<"http://jabber.org/protocol/chatstates">>;
-get_ns({chatstate_composing}) ->
+get_ns({chatstatecomposing}) ->
     <<"http://jabber.org/protocol/chatstates">>;
-get_ns({chatstate_gone}) ->
+get_ns({chatstategone}) ->
     <<"http://jabber.org/protocol/chatstates">>;
-get_ns({chatstate_inactive}) ->
+get_ns({chatstateinactive}) ->
     <<"http://jabber.org/protocol/chatstates">>;
-get_ns({chatstate_paused}) ->
+get_ns({chatstatepaused}) ->
     <<"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({csiactive}) -> <<"urn:xmpp:csi:0">>;
+get_ns({csiinactive}) -> <<"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}.
+    {csiinactive}.
 
-encode_csi_inactive({csi_inactive}, _xmlns_attrs) ->
+encode_csi_inactive({csiinactive}, _xmlns_attrs) ->
     _els = [],
     _attrs = _xmlns_attrs,
     {xmlel, <<"inactive">>, _attrs, _els}.
 
 decode_csi_active(__TopXMLNS, __IgnoreEls,
                  {xmlel, <<"active">>, _attrs, _els}) ->
-    {csi_active}.
+    {csiactive}.
 
-encode_csi_active({csi_active}, _xmlns_attrs) ->
+encode_csi_active({csiactive}, _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}.
+    {chatstatepaused}.
 
-encode_chatstate_paused({chatstate_paused},
+encode_chatstate_paused({chatstatepaused},
                        _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}.
+    {chatstateinactive}.
 
-encode_chatstate_inactive({chatstate_inactive},
+encode_chatstate_inactive({chatstateinactive},
                          _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}.
+    {chatstategone}.
 
-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}.
+    {chatstatecomposing}.
 
-encode_chatstate_composing({chatstate_composing},
+encode_chatstate_composing({chatstatecomposing},
                           _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}.
+    {chatstateactive}.
 
-encode_chatstate_active({chatstate_active},
+encode_chatstate_active({chatstateactive},
                        _xmlns_attrs) ->
     _els = [],
     _attrs = _xmlns_attrs,
index 6e142414f9b79b7eccc34288164f650eaf0d3304..c421aa1d67a1d3e28058831cdb9154e37f8072cf 100644 (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()}).
 
 -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()}).
 
 
 -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(),
                       mode = tcp :: 'tcp' | 'udp',
                       sid :: binary()}).
 
--record(chatstate_active, {}).
-
 -record(vcard_org, {name :: binary(),
                     units = [] :: [binary()]}).
 
 -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{}.
+
index c5d9013ed3b75f99348101827502eb7a7bc2b68f..f8ed72af9c3ceba2f7e147b6e6947cb0816e6d37 100644 (file)
            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 = {chatstateactive}}).
 
 -xml(chatstate_composing,
      #elem{name = <<"composing">>,
            xmlns = <<"http://jabber.org/protocol/chatstates">>,
-           result = {chatstate_composing}}).
+           result = {chatstatecomposing}}).
 
 -xml(chatstate_gone,
      #elem{name = <<"gone">>,
            xmlns = <<"http://jabber.org/protocol/chatstates">>,
-           result = {chatstate_gone}}).
+           result = {chatstategone}}).
 
 -xml(chatstate_inactive,
      #elem{name = <<"inactive">>,
            xmlns = <<"http://jabber.org/protocol/chatstates">>,
-           result = {chatstate_inactive}}).
+           result = {chatstateinactive}}).
 
 -xml(chatstate_paused,
      #elem{name = <<"paused">>,
            xmlns = <<"http://jabber.org/protocol/chatstates">>,
-           result = {chatstate_paused}}).
+           result = {chatstatepaused}}).
 
 -xml(delay,
      #elem{name = <<"delay">>,
           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 = {csiactive}}).
 
 -xml(csi_inactive,
      #elem{name = <<"inactive">>,
           xmlns = <<"urn:xmpp:csi:0">>,
-          result = {csi_inactive}}).
+          result = {csiinactive}}).
 
 -xml(feature_sm,
      #elem{name = <<"sm">>,