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

* src/web/ejabberd_http_poll.erl: Refactoring. Moved c2s limits acquisition to a separate module.

* src/ejabberd_c2s_config.erl: Likewise.

SVN Revision: 966
This commit is contained in:
Mickaël Rémond 2007-11-02 14:45:06 +00:00
parent 426f6072dc
commit 08cfab8a06
3 changed files with 50 additions and 30 deletions

View File

@ -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> 2007-11-01 Mickael Remond <mremond@process-one.net>
* src/web/ejabberd_http_poll.erl: Support for c2s ACL access, * src/web/ejabberd_http_poll.erl: Support for c2s ACL access,

View File

@ -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).

View File

@ -160,7 +160,7 @@ init([ID, Key]) ->
%% each connector. The default behaviour should be however to use %% each connector. The default behaviour should be however to use
%% the default c2s restrictions if not defined for the current %% the default c2s restrictions if not defined for the current
%% connector. %% connector.
Opts = get_c2s_opts(), Opts = ejabberd_c2s_config:get_c2s_limits(),
ejabberd_socket:start(ejabberd_c2s, ?MODULE, {http_poll, self()}, Opts), ejabberd_socket:start(ejabberd_c2s, ?MODULE, {http_poll, self()}, Opts),
%{ok, C2SPid} = ejabberd_c2s:start({?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 %%% 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) -> http_put(ID, Key, NewKey, Packet) ->
case mnesia:dirty_read({http_poll, ID}) of case mnesia:dirty_read({http_poll, ID}) of
[] -> [] ->