]> granicus.if.org Git - ejabberd/commitdiff
* src/gen_mod.erl: First store module options in ETS and Mnesia,
authorBadlop <badlop@process-one.net>
Wed, 26 Nov 2008 15:10:38 +0000 (15:10 +0000)
committerBadlop <badlop@process-one.net>
Wed, 26 Nov 2008 15:10:38 +0000 (15:10 +0000)
then start the module. In case of failure, remove options from
ETS. Until now the module was started before the options were
stored in database, and some modules started incorrectly because
they couldn't access the options from database; for instance
mod_muc_room required this for reading max_users option.

* src/mod_muc/mod_muc_room.erl: Include the value of max_users
service option and the current max_users room option in the list
of allowed room limit values.

SVN Revision: 1685

ChangeLog
src/gen_mod.erl
src/mod_muc/mod_muc_room.erl

index ed9072a86a00070ad8b6a0752d11a1e6ab91c704..7679c38df3cb34105638193e2dd91388796e69cc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-11-26  Badlop  <badlop@process-one.net>
+
+       * src/gen_mod.erl: First store module options in ETS and Mnesia,
+       then start the module. In case of failure, remove options from
+       ETS. Until now the module was started before the options were
+       stored in database, and some modules started incorrectly because
+       they couldn't access the options from database; for instance
+       mod_muc_room required this for reading max_users option.
+
+       * src/mod_muc/mod_muc_room.erl: Include the value of max_users
+       service option and the current max_users room option in the list
+       of allowed room limit values.
+
 2008-10-17  Christophe Romain <christophe.romain@process-one.net>
 
        * src/mod_pubsub/node_pep.erl: Fix get_node_affiliations resultset to
index 0457538146d04697ac2f8061a2d99cbd5c27bf97..49f4991a742b7bf49bfea1deb391180d5f634a65 100644 (file)
@@ -62,14 +62,16 @@ start() ->
 
 
 start_module(Host, Module, Opts) ->
+    set_module_opts_mnesia(Host, Module, Opts),
+    ets:insert(ejabberd_modules,
+              #ejabberd_module{module_host = {Module, Host},
+                               opts = Opts}),
     case catch Module:start(Host, Opts) of
        {'EXIT', Reason} ->
+           del_module_mnesia(Host, Module),
+           ets:delete(ejabberd_modules, {Module, Host}),
            ?ERROR_MSG("~p", [Reason]);
        _ ->
-           set_module_opts_mnesia(Host, Module, Opts),
-           ets:insert(ejabberd_modules,
-                      #ejabberd_module{module_host = {Module, Host},
-                                       opts = Opts}),
            ok
     end.
 
index 16268196f268dbbfad241c23c9432c0c26fd239f..edd5912ea9cf407d52cc6535536e9a4097497df0 100644 (file)
@@ -2654,11 +2654,25 @@ check_allowed_persistent_change(XEl, StateData, From) ->
 -define(PRIVATEXFIELD(Label, Var, Val),
        ?XFIELD("text-private", Label, Var, Val)).
 
+get_default_room_maxusers(RoomState) ->
+    DefRoomOpts = gen_mod:get_module_opt(RoomState#state.server_host, mod_muc, default_room_options, ?MAX_USERS_DEFAULT),
+    RoomState2 = set_opts(DefRoomOpts, RoomState),
+    (RoomState2#state.config)#config.max_users.
 
 get_config(Lang, StateData, From) ->
     {_AccessRoute, _AccessCreate, _AccessAdmin, AccessPersistent} = StateData#state.access,
     ServiceMaxUsers = get_service_max_users(StateData),
+
+    DefaultRoomMaxUsers = get_default_room_maxusers(StateData), %+++
+    ?INFO_MSG("DefaultMaxUsers: ~p", [DefaultRoomMaxUsers]),
+
     Config = StateData#state.config,
+    {MaxUsersRoomInteger, MaxUsersRoomString} =
+       case get_max_users(StateData) of
+           N when is_integer(N) ->
+               {N, erlang:integer_to_list(N)};
+           _ -> {0, "none"}
+       end,
     Res =
        [{xmlelement, "title", [],
          [{xmlcdata, translate:translate(Lang, "Configuration for ") ++
@@ -2701,13 +2715,7 @@ get_config(Lang, StateData, From) ->
          [{"type", "list-single"},
           {"label", translate:translate(Lang, "Maximum Number of Occupants")},
           {"var", "muc#roomconfig_maxusers"}],
-         [{xmlelement, "value", [], [{xmlcdata,
-                                      case get_max_users(StateData) of
-                                          N when is_integer(N) ->
-                                              erlang:integer_to_list(N);
-                                          _ -> "none"
-                                      end
-                                     }]}] ++
+         [{xmlelement, "value", [], [{xmlcdata, MaxUsersRoomString}]}] ++
          if
              is_integer(ServiceMaxUsers) -> [];
              true ->
@@ -2718,7 +2726,8 @@ get_config(Lang, StateData, From) ->
          [{xmlelement, "option", [{"label", erlang:integer_to_list(N)}],
            [{xmlelement, "value", [],
              [{xmlcdata, erlang:integer_to_list(N)}]}]} ||
-             N <- ?MAX_USERS_DEFAULT_LIST, N =< ServiceMaxUsers]
+             N <- lists:usort([ServiceMaxUsers, DefaultRoomMaxUsers, MaxUsersRoomInteger |
+                              ?MAX_USERS_DEFAULT_LIST]), N =< ServiceMaxUsers]
         },
         {xmlelement, "field",
          [{"type", "list-single"},