summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ejabberd.erl19
-rw-r--r--src/ejabberd_auth.erl4
-rw-r--r--src/mod_pubsub.erl15
3 files changed, 27 insertions, 11 deletions
diff --git a/src/ejabberd.erl b/src/ejabberd.erl
index 4edab98f..1d2d7790 100644
--- a/src/ejabberd.erl
+++ b/src/ejabberd.erl
@@ -37,7 +37,7 @@
-protocol({xep, 270, '1.0'}).
-export([start/0, stop/0, start_app/1, start_app/2,
- get_pid_file/0, check_app/1]).
+ get_pid_file/0, check_app/1, module_name/1]).
-include("logger.hrl").
@@ -148,3 +148,20 @@ get_module_file(App, Mod) ->
Dir ->
filename:join([Dir, BaseName ++ ".beam"])
end.
+
+module_name([Dir, _, <<H,T/binary>> | _] = Mod) when H >= 65, H =< 90 ->
+ Module = str:join([elixir_name(M) || M<-tl(Mod)], <<>>),
+ Prefix = case elixir_name(Dir) of
+ <<"Ejabberd">> -> <<"Elixir.Ejabberd.">>;
+ Lib -> <<"Elixir.Ejabberd.", Lib/binary, ".">>
+ end,
+ misc:binary_to_atom(<<Prefix/binary, Module/binary>>);
+module_name([<<"ejabberd">> | _] = Mod) ->
+ misc:binary_to_atom(str:join(Mod,$_));
+module_name(Mod) when is_list(Mod) ->
+ misc:binary_to_atom(str:join(tl(Mod),$_)).
+
+elixir_name(<<H,T/binary>>) when H >= 65, H =< 90 ->
+ <<H, T/binary>>;
+elixir_name(<<H,T/binary>>) ->
+ <<(H-32), T/binary>>.
diff --git a/src/ejabberd_auth.erl b/src/ejabberd_auth.erl
index 4ab82a4e..f49bef43 100644
--- a/src/ejabberd_auth.erl
+++ b/src/ejabberd_auth.erl
@@ -735,8 +735,8 @@ auth_modules(Server) ->
LServer = jid:nameprep(Server),
Default = ejabberd_config:default_db(LServer, ?MODULE),
Methods = ejabberd_config:get_option({auth_method, LServer}, [Default]),
- [misc:binary_to_atom(<<"ejabberd_auth_",
- (misc:atom_to_binary(M))/binary>>)
+ [ejabberd:module_name([<<"ejabberd">>, <<"auth">>,
+ misc:atom_to_binary(M)])
|| M <- Methods].
-spec match_passwords(password(), password(),
diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl
index e84d727e..877c884c 100644
--- a/src/mod_pubsub.erl
+++ b/src/mod_pubsub.erl
@@ -3380,11 +3380,11 @@ tree(Host) ->
tree(_Host, <<"virtual">>) ->
nodetree_virtual; % special case, virtual does not use any backend
tree(Host, Name) ->
- submodule(Host, <<"nodetree_", Name/binary>>).
+ submodule(Host, <<"nodetree">>, Name).
-spec plugin(host(), binary()) -> atom().
plugin(Host, Name) ->
- submodule(Host, <<"node_", Name/binary>>).
+ submodule(Host, <<"node">>, Name).
-spec plugins(host()) -> [binary()].
plugins(Host) ->
@@ -3396,14 +3396,13 @@ plugins(Host) ->
-spec subscription_plugin(host()) -> atom().
subscription_plugin(Host) ->
- submodule(Host, <<"pubsub_subscription">>).
+ submodule(Host, <<"pubsub">>, <<"subscription">>).
--spec submodule(host(), binary()) -> atom().
-submodule(Host, Name) ->
+-spec submodule(host(), binary(), binary()) -> atom().
+submodule(Host, Type, Name) ->
case gen_mod:db_type(serverhost(Host), ?MODULE) of
- mnesia -> misc:binary_to_atom(Name);
- Type -> misc:binary_to_atom(<<Name/binary, "_",
- (misc:atom_to_binary(Type))/binary>>)
+ mnesia -> ejabberd:module_name([<<"pubsub">>, Type, Name]);
+ Db -> ejabberd:module_name([<<"pubsub">>, Type, Name, Db])
end.
-spec config(binary(), any()) -> any().