mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-04 16:40:36 +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:
parent
d5e14e686a
commit
7c24a9a400
10
ChangeLog
10
ChangeLog
@ -1,3 +1,4 @@
|
||||
v v v v v v v
|
||||
2007-08-01 Mickael Remond <mickael.remond@process-one.net>
|
||||
|
||||
* doc/guide.tex: Front page table formatting that render correctly
|
||||
@ -20,6 +21,15 @@
|
||||
* src/Makefile.in: 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>
|
||||
|
||||
* src/mod_version.erl: Added option to hide OS version (thanks to
|
||||
|
@ -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
|
||||
the interval delay. Intermediate presence packets are silently
|
||||
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}
|
||||
|
||||
Examples:
|
||||
@ -2115,6 +2127,26 @@ defined, but some user restriction could be added as well:
|
||||
]}.
|
||||
\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}
|
||||
|
||||
The Multi-Users Chat module now supports clustering and load
|
||||
|
@ -3,12 +3,10 @@
|
||||
%%% Author : Alexey Shchepin <alexey@sevcom.net>
|
||||
%%% Purpose : MUC support (JEP-0045)
|
||||
%%% Created : 19 Mar 2003 by Alexey Shchepin <alexey@sevcom.net>
|
||||
%%% Id : $Id$
|
||||
%%%----------------------------------------------------------------------
|
||||
|
||||
-module(mod_muc).
|
||||
-author('alexey@sevcom.net').
|
||||
-vsn('$Revision$ ').
|
||||
|
||||
-behaviour(gen_server).
|
||||
-behaviour(gen_mod).
|
||||
@ -36,7 +34,7 @@
|
||||
-record(muc_online_room, {name_host, pid}).
|
||||
-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).
|
||||
|
||||
@ -156,12 +154,14 @@ init([Host, Opts]) ->
|
||||
AccessAdmin = gen_mod:get_opt(access_admin, Opts, none),
|
||||
AccessPersistent = gen_mod:get_opt(access_persistent, Opts, all),
|
||||
HistorySize = gen_mod:get_opt(history_size, Opts, 20),
|
||||
DefRoomOpts = gen_mod:get_opt(default_room_options, Opts, []),
|
||||
ejabberd_router:register_route(MyHost),
|
||||
load_permanent_rooms(MyHost, Host, {Access, AccessCreate, AccessAdmin, AccessPersistent},
|
||||
HistorySize),
|
||||
{ok, #state{host = MyHost,
|
||||
server_host = Host,
|
||||
access = {Access, AccessCreate, AccessAdmin, AccessPersistent},
|
||||
default_room_opts = DefRoomOpts,
|
||||
history_size = HistorySize}}.
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
@ -195,8 +195,9 @@ handle_info({route, From, To, Packet},
|
||||
#state{host = Host,
|
||||
server_host = ServerHost,
|
||||
access = Access,
|
||||
default_room_opts = DefRoomOpts,
|
||||
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} ->
|
||||
?ERROR_MSG("~p", [Reason]);
|
||||
_ ->
|
||||
@ -254,11 +255,11 @@ stop_supervisor(Host) ->
|
||||
supervisor:terminate_child(ejabberd_sup, Proc),
|
||||
supervisor:delete_child(ejabberd_sup, Proc).
|
||||
|
||||
do_route(Host, ServerHost, Access, HistorySize, From, To, Packet) ->
|
||||
{AccessRoute, _AccessCreate, _AccessAdmin, AccessPersistent} = Access,
|
||||
do_route(Host, ServerHost, Access, HistorySize, From, To, Packet, DefRoomOpts) ->
|
||||
{AccessRoute, _AccessCreate, _AccessAdmin, _AccessPersistent} = Access,
|
||||
case acl:match_rule(ServerHost, AccessRoute, From) of
|
||||
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,
|
||||
Lang = xml:get_attr_s("xml:lang", Attrs),
|
||||
@ -269,8 +270,8 @@ do_route(Host, ServerHost, Access, HistorySize, From, To, Packet) ->
|
||||
end.
|
||||
|
||||
|
||||
do_route1(Host, ServerHost, Access, HistorySize, From, To, Packet) ->
|
||||
{_AccessRoute, AccessCreate, AccessAdmin, AccessPersistent} = Access,
|
||||
do_route1(Host, ServerHost, Access, HistorySize, From, To, Packet, DefRoomOpts) ->
|
||||
{_AccessRoute, AccessCreate, AccessAdmin, _AccessPersistent} = Access,
|
||||
{Room, _, Nick} = jlib:jid_tolower(To),
|
||||
{xmlelement, Name, Attrs, _Els} = Packet,
|
||||
case Room of
|
||||
@ -395,7 +396,7 @@ do_route1(Host, ServerHost, Access, HistorySize, From, To, Packet) ->
|
||||
{ok, Pid} = mod_muc_room:start(
|
||||
Host, ServerHost, Access,
|
||||
Room, HistorySize, From,
|
||||
Nick),
|
||||
Nick, DefRoomOpts),
|
||||
register_room(Host, Room, Pid),
|
||||
mod_muc_room:route(Pid, From, Nick, Packet),
|
||||
ok;
|
||||
|
@ -14,9 +14,9 @@
|
||||
|
||||
|
||||
%% External exports
|
||||
-export([start_link/7,
|
||||
-export([start_link/8,
|
||||
start_link/6,
|
||||
start/7,
|
||||
start/8,
|
||||
start/6,
|
||||
route/4]).
|
||||
|
||||
@ -90,18 +90,18 @@
|
||||
%%%----------------------------------------------------------------------
|
||||
%%% 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: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) ->
|
||||
Supervisor = gen_mod:get_module_proc(ServerHost, ejabberd_mod_muc_sup),
|
||||
supervisor:start_child(
|
||||
Supervisor, [Host, ServerHost, Access, Room, HistorySize, Opts]).
|
||||
|
||||
start_link(Host, ServerHost, Access, Room, HistorySize, Creator, Nick) ->
|
||||
gen_fsm:start_link(?MODULE, [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, DefRoomOpts],
|
||||
?FSMOPTS).
|
||||
|
||||
start_link(Host, ServerHost, Access, Room, HistorySize, Opts) ->
|
||||
@ -119,7 +119,7 @@ start_link(Host, ServerHost, Access, Room, HistorySize, Opts) ->
|
||||
%% ignore |
|
||||
%% {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{host = Host,
|
||||
server_host = ServerHost,
|
||||
@ -128,7 +128,8 @@ init([Host, ServerHost, Access, Room, HistorySize, Creator, _Nick]) ->
|
||||
history = lqueue_new(HistorySize),
|
||||
jid = jlib:make_jid(Room, Host, ""),
|
||||
just_created = true}),
|
||||
{ok, normal_state, State};
|
||||
State1 = set_opts(DefRoomOpts, State),
|
||||
{ok, normal_state, State1};
|
||||
init([Host, ServerHost, Access, Room, HistorySize, Opts]) ->
|
||||
State = set_opts(Opts, #state{host = Host,
|
||||
server_host = ServerHost,
|
||||
@ -315,7 +316,7 @@ normal_state({route, From, "",
|
||||
end;
|
||||
|
||||
normal_state({route, From, Nick,
|
||||
{xmlelement, "presence", Attrs, _Els} = Packet},
|
||||
{xmlelement, "presence", _Attrs, _Els} = Packet},
|
||||
StateData) ->
|
||||
Activity = case ?DICT:find(jlib:jid_tolower(From),
|
||||
StateData#state.activity) of
|
||||
@ -593,7 +594,7 @@ code_change(_OldVsn, StateName, StateData, _Extra) ->
|
||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
||||
%% {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),
|
||||
StateData#state.activity) of
|
||||
{ok, A} -> A;
|
||||
|
Loading…
Reference in New Issue
Block a user