diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | src/ejabberd_c2s_config.erl | 43 | ||||
-rw-r--r-- | src/web/ejabberd_http_poll.erl | 31 |
3 files changed, 50 insertions, 30 deletions
@@ -1,3 +1,9 @@ +2007-11-02 Mickael Remond <mremond@process-one.net> + + * src/web/ejabberd_http_poll.erl: Refactoring. Moved c2s limits + acquisition to a separate module. + * src/ejabberd_c2s_config.erl: Likewise. + 2007-11-01 Mickael Remond <mremond@process-one.net> * src/web/ejabberd_http_poll.erl: Support for c2s ACL access, diff --git a/src/ejabberd_c2s_config.erl b/src/ejabberd_c2s_config.erl new file mode 100644 index 000000000..77013a8d0 --- /dev/null +++ b/src/ejabberd_c2s_config.erl @@ -0,0 +1,43 @@ +%%%---------------------------------------------------------------------- +%%% File : ejabberd_c2s_config.erl +%%% Author : Mickael Remond <mremond@process-one.net> +%%% Purpose : Functions for c2s interactions from other client +%%% connector modules +%%% Created : 2 Nov 2007 by Mickael Remond <mremond@process-one.net> +%%% Id : $Id: $ +%%%---------------------------------------------------------------------- + +-module(ejabberd_c2s_config). +-author('mremond@process-one.net'). +-svn('$Revision: 965 $ '). + +-export([get_c2s_limits/0]). + +%% Get first c2s configuration limitations to apply it to other c2s +%% connectors. +get_c2s_limits() -> + case ejabberd_config:get_local_option(listen) of + undefined -> + []; + C2SFirstListen -> + case lists:keysearch(ejabberd_c2s, 2, C2SFirstListen) of + false -> + []; + {value, {_Port, ejabberd_c2s, Opts}} -> + select_opts_values(Opts) + end + end. +%% Only get access, shaper and max_stanza_size values +select_opts_values(Opts) -> + select_opts_values(Opts, []). +select_opts_values([], SelectedValues) -> + SelectedValues; +select_opts_values([{access,Value}|Opts], SelectedValues) -> + select_opts_values(Opts, [{access, Value}|SelectedValues]); +select_opts_values([{shaper,Value}|Opts], SelectedValues) -> + select_opts_values(Opts, [{shaper, Value}|SelectedValues]); +select_opts_values([{max_stanza_size,Value}|Opts], SelectedValues) -> + select_opts_values(Opts, [{max_stanza_size, Value}|SelectedValues]); +select_opts_values([_Opt|Opts], SelectedValues) -> + select_opts_values(Opts, SelectedValues). + diff --git a/src/web/ejabberd_http_poll.erl b/src/web/ejabberd_http_poll.erl index ba85c940a..0b81fad53 100644 --- a/src/web/ejabberd_http_poll.erl +++ b/src/web/ejabberd_http_poll.erl @@ -160,7 +160,7 @@ init([ID, Key]) -> %% each connector. The default behaviour should be however to use %% the default c2s restrictions if not defined for the current %% connector. - Opts = get_c2s_opts(), + Opts = ejabberd_c2s_config:get_c2s_limits(), ejabberd_socket:start(ejabberd_c2s, ?MODULE, {http_poll, self()}, Opts), %{ok, C2SPid} = ejabberd_c2s:start({?MODULE, {http_poll, self()}}, Opts), @@ -326,35 +326,6 @@ terminate(Reason, StateName, StateData) -> %%% Internal functions %%%---------------------------------------------------------------------- -%% Get first c2s configuration limitations to apply it to other c2s -%% connectors. -get_c2s_opts() -> - case ejabberd_config:get_local_option(listen) of - undefined -> - []; - C2SFirstListen -> - case lists:keysearch(ejabberd_c2s, 2, C2SFirstListen) of - false -> - []; - {value, {_Port, ejabberd_c2s, Opts}} -> - select_opts_values(Opts) - end - end. -%% Only get access, shaper and max_stanza_size values -select_opts_values(Opts) -> - select_opts_values(Opts, []). -select_opts_values([], SelectedValues) -> - SelectedValues; -select_opts_values([{access,Value}|Opts], SelectedValues) -> - select_opts_values(Opts, [{access, Value}|SelectedValues]); -select_opts_values([{shaper,Value}|Opts], SelectedValues) -> - select_opts_values(Opts, [{shaper, Value}|SelectedValues]); -select_opts_values([{max_stanza_size,Value}|Opts], SelectedValues) -> - select_opts_values(Opts, [{max_stanza_size, Value}|SelectedValues]); -select_opts_values([_Opt|Opts], SelectedValues) -> - select_opts_values(Opts, SelectedValues). - - http_put(ID, Key, NewKey, Packet) -> case mnesia:dirty_read({http_poll, ID}) of [] -> |