]> 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 63859f40a3b5fa5dc0bad092871801b0cfdeed05..002fe4014ae07941bc3ab0678ca4db7ba8fef0cd 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 bbc4e860d16ee42ff57b947597599eee7f97aae8..03ebc1635145ea3bce2be46689e85cd15f2aa235 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 e8b314c531fcda3e029bb0a0eac8eeab73e483d2..6c6579ffeb583b6e31087480d34a4c4c04970f19 100644 (file)
@@ -2626,11 +2626,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 ") ++
@@ -2670,13 +2684,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 ->
@@ -2687,7 +2695,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"},