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

* src/mod_muc/mod_muc.erl: Added default_room_options option

(thanks to Etan Reisner and Badlop)
* src/mod_muc/mod_muc_room.erl: Likewise
* doc/guide.tex: Updated

SVN Revision: 856
This commit is contained in:
Alexey Shchepin 2007-08-02 02:30:25 +00:00
parent d5e14e686a
commit 7c24a9a400
4 changed files with 64 additions and 20 deletions

View File

@ -1,3 +1,4 @@
v v v v v v v
2007-08-01 Mickael Remond <mickael.remond@process-one.net> 2007-08-01 Mickael Remond <mickael.remond@process-one.net>
* doc/guide.tex: Front page table formatting that render correctly * doc/guide.tex: Front page table formatting that render correctly
@ -20,6 +21,15 @@
* src/Makefile.in: Likewise. * src/Makefile.in: Likewise.
* src/configure.ac: Likewise. * src/configure.ac: Likewise.
*************
2007-08-02 Alexey Shchepin <alexey@sevcom.net>
* src/mod_muc/mod_muc.erl: Added default_room_options option
(thanks to Etan Reisner and Badlop)
* src/mod_muc/mod_muc_room.erl: Likewise
* doc/guide.tex: Updated
^ ^ ^ ^ ^ ^ ^
2007-07-31 Alexey Shchepin <alexey@sevcom.net> 2007-07-31 Alexey Shchepin <alexey@sevcom.net>
* src/mod_version.erl: Added option to hide OS version (thanks to * src/mod_version.erl: Added option to hide OS version (thanks to

View File

@ -2039,6 +2039,18 @@ interval, the presence is cached by ejabberd and only the last
presence is broadcasted to all users in the room after expiration of presence is broadcasted to all users in the room after expiration of
the interval delay. Intermediate presence packets are silently the interval delay. Intermediate presence packets are silently
discarded. A good value for this option is 4 seconds. discarded. A good value for this option is 4 seconds.
\titem{default\_room\_opts} \ind{options!default\_room\_opts}This option allow
to define the desired default room options.
Obviously, the room creator can modify the room options at any time.
The available room options are:
\option{allow\_change\_subj}, \option{allow\_private\_messages},
\option{allow\_query\_users}, \option{allow\_user\_invites},
\option{anonymous}, \option{logging}, \option{members\_by\_default},
\option{members\_only}, \option{moderated}, \option{password},
\option{password\_protected}, \option{persistent},
\option{public}, \option{public\_list}, \option{title}.
All of them can be set to \option{true} or \option{false},
except \option{password} and \option{title} which are strings.
\end{description} \end{description}
Examples: Examples:
@ -2115,6 +2127,26 @@ defined, but some user restriction could be added as well:
]}. ]}.
\end{verbatim} \end{verbatim}
\item This example shows how to use \option{default\_room\_opts} to make sure
newly created chatrooms have by default those options.
\begin{verbatim}
{modules,
[
...
{mod_muc, [{access, muc_access},
{access_create, muc_admins},
{default_room_options, [
{allow_change_subj, false},
{allow_query_users, true},
{allow_private_messages, true},
{members_by_default, false},
{title, "New chatroom"},
{anonymous, false}
]},
{access_admin, muc_admins}]},
...
]}.
\end{verbatim}
\end{itemize} \end{itemize}
The Multi-Users Chat module now supports clustering and load The Multi-Users Chat module now supports clustering and load

View File

@ -3,12 +3,10 @@
%%% Author : Alexey Shchepin <alexey@sevcom.net> %%% Author : Alexey Shchepin <alexey@sevcom.net>
%%% Purpose : MUC support (JEP-0045) %%% Purpose : MUC support (JEP-0045)
%%% Created : 19 Mar 2003 by Alexey Shchepin <alexey@sevcom.net> %%% Created : 19 Mar 2003 by Alexey Shchepin <alexey@sevcom.net>
%%% Id : $Id$
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
-module(mod_muc). -module(mod_muc).
-author('alexey@sevcom.net'). -author('alexey@sevcom.net').
-vsn('$Revision$ ').
-behaviour(gen_server). -behaviour(gen_server).
-behaviour(gen_mod). -behaviour(gen_mod).
@ -36,7 +34,7 @@
-record(muc_online_room, {name_host, pid}). -record(muc_online_room, {name_host, pid}).
-record(muc_registered, {us_host, nick}). -record(muc_registered, {us_host, nick}).
-record(state, {host, server_host, access, history_size}). -record(state, {host, server_host, access, history_size, default_room_opts}).
-define(PROCNAME, ejabberd_mod_muc). -define(PROCNAME, ejabberd_mod_muc).
@ -156,12 +154,14 @@ init([Host, Opts]) ->
AccessAdmin = gen_mod:get_opt(access_admin, Opts, none), AccessAdmin = gen_mod:get_opt(access_admin, Opts, none),
AccessPersistent = gen_mod:get_opt(access_persistent, Opts, all), AccessPersistent = gen_mod:get_opt(access_persistent, Opts, all),
HistorySize = gen_mod:get_opt(history_size, Opts, 20), HistorySize = gen_mod:get_opt(history_size, Opts, 20),
DefRoomOpts = gen_mod:get_opt(default_room_options, Opts, []),
ejabberd_router:register_route(MyHost), ejabberd_router:register_route(MyHost),
load_permanent_rooms(MyHost, Host, {Access, AccessCreate, AccessAdmin, AccessPersistent}, load_permanent_rooms(MyHost, Host, {Access, AccessCreate, AccessAdmin, AccessPersistent},
HistorySize), HistorySize),
{ok, #state{host = MyHost, {ok, #state{host = MyHost,
server_host = Host, server_host = Host,
access = {Access, AccessCreate, AccessAdmin, AccessPersistent}, access = {Access, AccessCreate, AccessAdmin, AccessPersistent},
default_room_opts = DefRoomOpts,
history_size = HistorySize}}. history_size = HistorySize}}.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
@ -195,8 +195,9 @@ handle_info({route, From, To, Packet},
#state{host = Host, #state{host = Host,
server_host = ServerHost, server_host = ServerHost,
access = Access, access = Access,
default_room_opts = DefRoomOpts,
history_size = HistorySize} = State) -> history_size = HistorySize} = State) ->
case catch do_route(Host, ServerHost, Access, HistorySize, From, To, Packet) of case catch do_route(Host, ServerHost, Access, HistorySize, From, To, Packet, DefRoomOpts) of
{'EXIT', Reason} -> {'EXIT', Reason} ->
?ERROR_MSG("~p", [Reason]); ?ERROR_MSG("~p", [Reason]);
_ -> _ ->
@ -254,11 +255,11 @@ stop_supervisor(Host) ->
supervisor:terminate_child(ejabberd_sup, Proc), supervisor:terminate_child(ejabberd_sup, Proc),
supervisor:delete_child(ejabberd_sup, Proc). supervisor:delete_child(ejabberd_sup, Proc).
do_route(Host, ServerHost, Access, HistorySize, From, To, Packet) -> do_route(Host, ServerHost, Access, HistorySize, From, To, Packet, DefRoomOpts) ->
{AccessRoute, _AccessCreate, _AccessAdmin, AccessPersistent} = Access, {AccessRoute, _AccessCreate, _AccessAdmin, _AccessPersistent} = Access,
case acl:match_rule(ServerHost, AccessRoute, From) of case acl:match_rule(ServerHost, AccessRoute, From) of
allow -> allow ->
do_route1(Host, ServerHost, Access, HistorySize, From, To, Packet); do_route1(Host, ServerHost, Access, HistorySize, From, To, Packet, DefRoomOpts);
_ -> _ ->
{xmlelement, _Name, Attrs, _Els} = Packet, {xmlelement, _Name, Attrs, _Els} = Packet,
Lang = xml:get_attr_s("xml:lang", Attrs), Lang = xml:get_attr_s("xml:lang", Attrs),
@ -269,8 +270,8 @@ do_route(Host, ServerHost, Access, HistorySize, From, To, Packet) ->
end. end.
do_route1(Host, ServerHost, Access, HistorySize, From, To, Packet) -> do_route1(Host, ServerHost, Access, HistorySize, From, To, Packet, DefRoomOpts) ->
{_AccessRoute, AccessCreate, AccessAdmin, AccessPersistent} = Access, {_AccessRoute, AccessCreate, AccessAdmin, _AccessPersistent} = Access,
{Room, _, Nick} = jlib:jid_tolower(To), {Room, _, Nick} = jlib:jid_tolower(To),
{xmlelement, Name, Attrs, _Els} = Packet, {xmlelement, Name, Attrs, _Els} = Packet,
case Room of case Room of
@ -395,7 +396,7 @@ do_route1(Host, ServerHost, Access, HistorySize, From, To, Packet) ->
{ok, Pid} = mod_muc_room:start( {ok, Pid} = mod_muc_room:start(
Host, ServerHost, Access, Host, ServerHost, Access,
Room, HistorySize, From, Room, HistorySize, From,
Nick), Nick, DefRoomOpts),
register_room(Host, Room, Pid), register_room(Host, Room, Pid),
mod_muc_room:route(Pid, From, Nick, Packet), mod_muc_room:route(Pid, From, Nick, Packet),
ok; ok;

View File

@ -14,9 +14,9 @@
%% External exports %% External exports
-export([start_link/7, -export([start_link/8,
start_link/6, start_link/6,
start/7, start/8,
start/6, start/6,
route/4]). route/4]).
@ -90,18 +90,18 @@
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
%%% API %%% API
%%%---------------------------------------------------------------------- %%%----------------------------------------------------------------------
start(Host, ServerHost, Access, Room, HistorySize, Creator, Nick) -> start(Host, ServerHost, Access, Room, HistorySize, Creator, Nick, DefRoomOpts) ->
Supervisor = gen_mod:get_module_proc(ServerHost, ejabberd_mod_muc_sup), Supervisor = gen_mod:get_module_proc(ServerHost, ejabberd_mod_muc_sup),
supervisor:start_child( supervisor:start_child(
Supervisor, [Host, ServerHost, Access, Room, HistorySize, Creator, Nick]). Supervisor, [Host, ServerHost, Access, Room, HistorySize, Creator, Nick, DefRoomOpts]).
start(Host, ServerHost, Access, Room, HistorySize, Opts) -> start(Host, ServerHost, Access, Room, HistorySize, Opts) ->
Supervisor = gen_mod:get_module_proc(ServerHost, ejabberd_mod_muc_sup), Supervisor = gen_mod:get_module_proc(ServerHost, ejabberd_mod_muc_sup),
supervisor:start_child( supervisor:start_child(
Supervisor, [Host, ServerHost, Access, Room, HistorySize, Opts]). Supervisor, [Host, ServerHost, Access, Room, HistorySize, Opts]).
start_link(Host, ServerHost, Access, Room, HistorySize, Creator, Nick) -> start_link(Host, ServerHost, Access, Room, HistorySize, Creator, Nick, DefRoomOpts) ->
gen_fsm:start_link(?MODULE, [Host, ServerHost, Access, Room, HistorySize, Creator, Nick], gen_fsm:start_link(?MODULE, [Host, ServerHost, Access, Room, HistorySize, Creator, Nick, DefRoomOpts],
?FSMOPTS). ?FSMOPTS).
start_link(Host, ServerHost, Access, Room, HistorySize, Opts) -> start_link(Host, ServerHost, Access, Room, HistorySize, Opts) ->
@ -119,7 +119,7 @@ start_link(Host, ServerHost, Access, Room, HistorySize, Opts) ->
%% ignore | %% ignore |
%% {stop, StopReason} %% {stop, StopReason}
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
init([Host, ServerHost, Access, Room, HistorySize, Creator, _Nick]) -> init([Host, ServerHost, Access, Room, HistorySize, Creator, _Nick, DefRoomOpts]) ->
State = set_affiliation(Creator, owner, State = set_affiliation(Creator, owner,
#state{host = Host, #state{host = Host,
server_host = ServerHost, server_host = ServerHost,
@ -128,7 +128,8 @@ init([Host, ServerHost, Access, Room, HistorySize, Creator, _Nick]) ->
history = lqueue_new(HistorySize), history = lqueue_new(HistorySize),
jid = jlib:make_jid(Room, Host, ""), jid = jlib:make_jid(Room, Host, ""),
just_created = true}), just_created = true}),
{ok, normal_state, State}; State1 = set_opts(DefRoomOpts, State),
{ok, normal_state, State1};
init([Host, ServerHost, Access, Room, HistorySize, Opts]) -> init([Host, ServerHost, Access, Room, HistorySize, Opts]) ->
State = set_opts(Opts, #state{host = Host, State = set_opts(Opts, #state{host = Host,
server_host = ServerHost, server_host = ServerHost,
@ -315,7 +316,7 @@ normal_state({route, From, "",
end; end;
normal_state({route, From, Nick, normal_state({route, From, Nick,
{xmlelement, "presence", Attrs, _Els} = Packet}, {xmlelement, "presence", _Attrs, _Els} = Packet},
StateData) -> StateData) ->
Activity = case ?DICT:find(jlib:jid_tolower(From), Activity = case ?DICT:find(jlib:jid_tolower(From),
StateData#state.activity) of StateData#state.activity) of
@ -593,7 +594,7 @@ code_change(_OldVsn, StateName, StateData, _Extra) ->
%% {next_state, NextStateName, NextStateData, Timeout} | %% {next_state, NextStateName, NextStateData, Timeout} |
%% {stop, Reason, NewStateData} %% {stop, Reason, NewStateData}
%%---------------------------------------------------------------------- %%----------------------------------------------------------------------
handle_info({process_presence, From}, normal_state = StateName, StateData) -> handle_info({process_presence, From}, normal_state = _StateName, StateData) ->
Activity = case ?DICT:find(jlib:jid_tolower(From), Activity = case ?DICT:find(jlib:jid_tolower(From),
StateData#state.activity) of StateData#state.activity) of
{ok, A} -> A; {ok, A} -> A;