diff --git a/include/logger.hrl b/include/logger.hrl index 936befab3..a407b2e21 100644 --- a/include/logger.hrl +++ b/include/logger.hrl @@ -42,3 +42,6 @@ false -> ok; _ -> 'Elixir.Logger':bare_log(error, io_lib:format(Format, Args), [?MODULE]) end). + +%% Uncomment if you want to debug p1_fsm/gen_fsm +%%-define(DBGFSM, true). diff --git a/include/mod_muc_room.hrl b/include/mod_muc_room.hrl index 5966a6e09..b4804114a 100644 --- a/include/mod_muc_room.hrl +++ b/include/mod_muc_room.hrl @@ -18,7 +18,7 @@ %%% %%%---------------------------------------------------------------------- --include("ejabberd.hrl"). +-include("type_compat.hrl"). -define(MAX_USERS_DEFAULT, 200). @@ -67,7 +67,7 @@ captcha_whitelist = (?SETS):empty() :: ?TGB_SET, mam = false :: boolean(), pubsub = <<"">> :: binary(), - lang = ?MYLANG :: binary() + lang = ejabberd_config:get_mylang() :: binary() }). -type config() :: #config{}. diff --git a/include/pubsub.hrl b/include/pubsub.hrl index 8926413b4..28950f5ff 100644 --- a/include/pubsub.hrl +++ b/include/pubsub.hrl @@ -18,8 +18,6 @@ %%% %%%---------------------------------------------------------------------- --include("ejabberd.hrl"). - %% ------------------------------- %% Pubsub constants -define(ERR_EXTENDED(E, C), mod_pubsub:extended_error(E, C)). diff --git a/include/scram.hrl b/include/scram.hrl new file mode 100644 index 000000000..156a6401a --- /dev/null +++ b/include/scram.hrl @@ -0,0 +1,28 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2018 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License along +%%% with this program; if not, write to the Free Software Foundation, Inc., +%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +%%% +%%%---------------------------------------------------------------------- + +-record(scram, {storedkey = <<"">> :: binary(), + serverkey = <<"">> :: binary(), + salt = <<"">> :: binary(), + iterationcount = 0 :: integer()}). + +-type scram() :: #scram{}. + +-define(SCRAM_DEFAULT_ITERATION_COUNT, 4096). diff --git a/include/ejabberd.hrl b/include/type_compat.hrl similarity index 60% rename from include/ejabberd.hrl rename to include/type_compat.hrl index 0baf8dd2c..bd5129c41 100644 --- a/include/ejabberd.hrl +++ b/include/type_compat.hrl @@ -18,41 +18,6 @@ %%% %%%---------------------------------------------------------------------- --ifndef(EJABBERD_HRL). --define(EJABBERD_HRL, true). - --define(VERSION, ejabberd_config:get_version()). - --define(MYHOSTS, ejabberd_config:get_myhosts()). - --define(MYNAME, hd(ejabberd_config:get_myhosts())). - --define(MYLANG, ejabberd_config:get_mylang()). - --define(MSGS_DIR, filename:join(["priv", "msgs"])). - --define(SQL_DIR, filename:join(["priv", "sql"])). - --define(CONFIG_PATH, <<"ejabberd.yml">>). - --define(LOG_PATH, "ejabberd.log"). - --define(EJABBERD_URI, <<"http://www.process-one.net/en/ejabberd/">>). - --define(COPYRIGHT, "Copyright (c) ProcessOne"). - -%%-define(DBGFSM, true). - --record(scram, - {storedkey = <<"">>, - serverkey = <<"">>, - salt = <<"">>, - iterationcount = 0 :: integer()}). - --type scram() :: #scram{}. - --define(SCRAM_DEFAULT_ITERATION_COUNT, 4096). - -ifdef(ERL_DEPRECATED_TYPES). -define(TDICT, dict()). @@ -68,5 +33,3 @@ -define(TQUEUE, queue:queue()). -endif. - --endif. diff --git a/src/acl.erl b/src/acl.erl index a102ffbc8..f0c437b02 100644 --- a/src/acl.erl +++ b/src/acl.erl @@ -43,7 +43,6 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("jid.hrl"). @@ -195,7 +194,7 @@ add_access(Host, Access, Rules) -> -spec load_from_config() -> ok. load_from_config() -> - Hosts = [global|?MYHOSTS], + Hosts = [global|ejabberd_config:get_myhosts()], lists:foreach( fun(Host) -> ACLs = ejabberd_config:get_option( @@ -453,7 +452,7 @@ acl_rule_matches({ip, {Net, Mask}}, #{ip := IP}, _Host) -> acl_rule_matches({user, {U, S}}, #{usr := {U, S, _}}, _Host) -> true; acl_rule_matches({user, U}, #{usr := {U, S, _}}, _Host) -> - lists:member(S, ?MYHOSTS); + lists:member(S, ejabberd_config:get_myhosts()); acl_rule_matches({server, S}, #{usr := {_, S, _}}, _Host) -> true; acl_rule_matches({resource, R}, #{usr := {_, _, R}}, _Host) -> @@ -467,7 +466,7 @@ acl_rule_matches({shared_group, G}, #{usr := {U, S, _}}, Host) -> acl_rule_matches({user_regexp, {UR, S}}, #{usr := {U, S, _}}, _Host) -> is_regexp_match(U, UR); acl_rule_matches({user_regexp, UR}, #{usr := {U, S, _}}, _Host) -> - lists:member(S, ?MYHOSTS) andalso is_regexp_match(U, UR); + lists:member(S, ejabberd_config:get_myhosts()) andalso is_regexp_match(U, UR); acl_rule_matches({server_regexp, SR}, #{usr := {_, S, _}}, _Host) -> is_regexp_match(S, SR); acl_rule_matches({resource_regexp, RR}, #{usr := {_, _, R}}, _Host) -> @@ -477,7 +476,7 @@ acl_rule_matches({node_regexp, {UR, SR}}, #{usr := {U, S, _}}, _Host) -> acl_rule_matches({user_glob, {UR, S}}, #{usr := {U, S, _}}, _Host) -> is_glob_match(U, UR); acl_rule_matches({user_glob, UR}, #{usr := {U, S, _}}, _Host) -> - lists:member(S, ?MYHOSTS) andalso is_glob_match(U, UR); + lists:member(S, ejabberd_config:get_myhosts()) andalso is_glob_match(U, UR); acl_rule_matches({server_glob, SR}, #{usr := {_, S, _}}, _Host) -> is_glob_match(S, SR); acl_rule_matches({resource_glob, RR}, #{usr := {_, _, R}}, _Host) -> diff --git a/src/acme_challenge.erl b/src/acme_challenge.erl index 5e8c09944..fb23c1743 100644 --- a/src/acme_challenge.erl +++ b/src/acme_challenge.erl @@ -14,7 +14,6 @@ %% 3. tls-sni-01: https://tools.ietf.org/html/draft-ietf-acme-acme-05#section-7.4 %% 4. (?) oob-01: https://tools.ietf.org/html/draft-ietf-acme-acme-05#section-7.5 --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("ejabberd_http.hrl"). diff --git a/src/cyrsasl.erl b/src/cyrsasl.erl index 032fd3586..223d5fe68 100644 --- a/src/cyrsasl.erl +++ b/src/cyrsasl.erl @@ -35,7 +35,6 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --include("ejabberd.hrl"). -include("logger.hrl"). -record(state, {}). diff --git a/src/cyrsasl_digest.erl b/src/cyrsasl_digest.erl index 08edf3020..628157876 100644 --- a/src/cyrsasl_digest.erl +++ b/src/cyrsasl_digest.erl @@ -32,7 +32,6 @@ -export([start/1, stop/0, mech_new/4, mech_step/2, parse/1, format_error/1, opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -behaviour(cyrsasl). diff --git a/src/cyrsasl_scram.erl b/src/cyrsasl_scram.erl index 99062a874..78eae8b44 100644 --- a/src/cyrsasl_scram.erl +++ b/src/cyrsasl_scram.erl @@ -31,7 +31,7 @@ -export([start/1, stop/0, mech_new/4, mech_step/2, format_error/1]). --include("ejabberd.hrl"). +-include("scram.hrl"). -include("logger.hrl"). -behaviour(cyrsasl). diff --git a/src/ejabberd_acme.erl b/src/ejabberd_acme.erl index 5980000f0..44d93da2c 100644 --- a/src/ejabberd_acme.erl +++ b/src/ejabberd_acme.erl @@ -19,7 +19,6 @@ terminate/2, code_change/3]). -export([start_link/0, opt_type/1, register_certfiles/0]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("ejabberd_commands.hrl"). diff --git a/src/ejabberd_acme_comm.erl b/src/ejabberd_acme_comm.erl index a5668d088..2a3efd543 100644 --- a/src/ejabberd_acme_comm.erl +++ b/src/ejabberd_acme_comm.erl @@ -22,7 +22,6 @@ %% delete_authz/3 ]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/ejabberd_admin.erl b/src/ejabberd_admin.erl index 67200925f..ef33f0c2b 100644 --- a/src/ejabberd_admin.erl +++ b/src/ejabberd_admin.erl @@ -61,7 +61,6 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("ejabberd_commands.hrl"). @@ -412,7 +411,7 @@ stop_kindly(DelaySeconds, AnnouncementTextString) -> ejabberd_listener, stop_listeners, []}, {"Sending announcement to connected users", mod_announce, send_announcement_to_all, - [?MYNAME, Subject, AnnouncementText]}, + [ejabberd_config:get_myname(), Subject, AnnouncementText]}, {"Sending service message to MUC rooms", ejabberd_admin, send_service_message_all_mucs, [Subject, AnnouncementText]}, @@ -446,7 +445,7 @@ send_service_message_all_mucs(Subject, AnnouncementText) -> ServerHost, mod_muc, <<"conference.@HOST@">>), mod_muc:broadcast_service_message(ServerHost, MUCHost, Message) end, - ?MYHOSTS). + ejabberd_config:get_myhosts()). %%% %%% ejabberd_update @@ -499,7 +498,7 @@ registered_users(Host) -> lists:map(fun({U, _S}) -> U end, SUsers). registered_vhosts() -> - ?MYHOSTS. + ejabberd_config:get_myhosts(). reload_config() -> ejabberd_config:reload_file(). @@ -549,13 +548,13 @@ delete_expired_messages() -> lists:foreach( fun(Host) -> {atomic, ok} = mod_offline:remove_expired_messages(Host) - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). delete_old_messages(Days) -> lists:foreach( fun(Host) -> {atomic, _} = mod_offline:remove_old_messages(Days, Host) - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). %%% %%% Mnesia management @@ -622,7 +621,7 @@ keep_tables() -> %% loaded modules keep_modules_tables() -> lists:map(fun(Module) -> module_tables(Module) end, - gen_mod:loaded_modules(?MYNAME)). + gen_mod:loaded_modules(ejabberd_config:get_myname())). %% TODO: This mapping should probably be moved to a callback function in each %% module. diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index c7486a5be..7efb9f54b 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -31,7 +31,6 @@ -export([start/2, prep_stop/1, stop/1]). --include("ejabberd.hrl"). -include("logger.hrl"). %%% @@ -58,7 +57,8 @@ start(normal, _Args) -> ejabberd_cluster:wait_for_sync(infinity), {T2, _} = statistics(wall_clock), ?INFO_MSG("ejabberd ~s is started in the node ~p in ~.2fs", - [?VERSION, node(), (T2-T1)/1000]), + [ejabberd_config:get_version(), + node(), (T2-T1)/1000]), lists:foreach(fun erlang:garbage_collect/1, processes()), {ok, SupPid}; Err -> @@ -83,7 +83,8 @@ prep_stop(State) -> %% All the processes were killed when this function is called stop(_State) -> - ?INFO_MSG("ejabberd ~s is stopped in the node ~p", [?VERSION, node()]), + ?INFO_MSG("ejabberd ~s is stopped in the node ~p", + [ejabberd_config:get_version(), node()]), delete_pid_file(), %%ejabberd_debug:stop(), ok. diff --git a/src/ejabberd_auth.erl b/src/ejabberd_auth.erl index 9807e1f92..0552f801a 100644 --- a/src/ejabberd_auth.erl +++ b/src/ejabberd_auth.erl @@ -48,7 +48,7 @@ -export([auth_modules/1, opt_type/1]). --include("ejabberd.hrl"). +-include("scram.hrl"). -include("logger.hrl"). -define(AUTH_CACHE, auth_cache). @@ -107,7 +107,7 @@ init([]) -> fun(Host, Acc) -> Modules = auth_modules(Host), maps:put(Host, Modules, Acc) - end, #{}, ?MYHOSTS), + end, #{}, ejabberd_config:get_myhosts()), lists:foreach( fun({Host, Modules}) -> start(Host, Modules) @@ -141,7 +141,7 @@ handle_cast(config_reloaded, #state{host_modules = HostModules} = State) -> stop(Host, OldModules -- NewModules), reload(Host, lists_intersection(OldModules, NewModules)), maps:put(Host, NewModules, Acc) - end, HostModules, ?MYHOSTS), + end, HostModules, ejabberd_config:get_myhosts()), init_cache(NewHostModules), {noreply, State#state{host_modules = NewHostModules}}; handle_cast(Msg, State) -> @@ -764,7 +764,7 @@ auth_modules() -> lists:flatmap( fun(Host) -> [{Host, Mod} || Mod <- auth_modules(Host)] - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). -spec auth_modules(binary()) -> [module()]. auth_modules(Server) -> diff --git a/src/ejabberd_auth_anonymous.erl b/src/ejabberd_auth_anonymous.erl index 4c726f21a..9d4b3aff5 100644 --- a/src/ejabberd_auth_anonymous.erl +++ b/src/ejabberd_auth_anonymous.erl @@ -44,7 +44,6 @@ get_users/2, count_users/2, store_type/1, plain_password_required/1, opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("jid.hrl"). diff --git a/src/ejabberd_auth_external.erl b/src/ejabberd_auth_external.erl index 03df71bb8..0a1515d34 100644 --- a/src/ejabberd_auth_external.erl +++ b/src/ejabberd_auth_external.erl @@ -35,7 +35,6 @@ try_register/3, user_exists/2, remove_user/2, store_type/1, plain_password_required/1, opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). %%%---------------------------------------------------------------------- diff --git a/src/ejabberd_auth_ldap.erl b/src/ejabberd_auth_ldap.erl index df9e01bff..5f5fad3fb 100644 --- a/src/ejabberd_auth_ldap.erl +++ b/src/ejabberd_auth_ldap.erl @@ -42,7 +42,6 @@ store_type/1, plain_password_required/1, opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("eldap.hrl"). diff --git a/src/ejabberd_auth_mnesia.erl b/src/ejabberd_auth_mnesia.erl index fce2e645f..004e74996 100644 --- a/src/ejabberd_auth_mnesia.erl +++ b/src/ejabberd_auth_mnesia.erl @@ -38,8 +38,8 @@ plain_password_required/1, use_cache/1]). -export([need_transform/1, transform/1]). --include("ejabberd.hrl"). -include("logger.hrl"). +-include("scram.hrl"). -include("ejabberd_auth.hrl"). -record(reg_users_counter, {vhost = <<"">> :: binary(), diff --git a/src/ejabberd_auth_riak.erl b/src/ejabberd_auth_riak.erl index c5df7554b..33c25424a 100644 --- a/src/ejabberd_auth_riak.erl +++ b/src/ejabberd_auth_riak.erl @@ -38,8 +38,8 @@ plain_password_required/1]). -export([passwd_schema/0]). --include("ejabberd.hrl"). -include("ejabberd_sql_pt.hrl"). +-include("scram.hrl"). -include("ejabberd_auth.hrl"). start(_Host) -> diff --git a/src/ejabberd_auth_sql.erl b/src/ejabberd_auth_sql.erl index 1372d1696..4d1cf0667 100644 --- a/src/ejabberd_auth_sql.erl +++ b/src/ejabberd_auth_sql.erl @@ -37,7 +37,7 @@ remove_user/2, store_type/1, plain_password_required/1, convert_to_scram/1, opt_type/1, export/1]). --include("ejabberd.hrl"). +-include("scram.hrl"). -include("logger.hrl"). -include("ejabberd_sql_pt.hrl"). -include("ejabberd_auth.hrl"). diff --git a/src/ejabberd_bosh.erl b/src/ejabberd_bosh.erl index 16cbcb6c1..b1519aedb 100644 --- a/src/ejabberd_bosh.erl +++ b/src/ejabberd_bosh.erl @@ -44,13 +44,10 @@ handle_sync_event/4, handle_info/3, terminate/3, code_change/4]). --include("ejabberd.hrl"). +-include("type_compat.hrl"). -include("logger.hrl"). - -include("xmpp.hrl"). - -include("ejabberd_http.hrl"). - -include("bosh.hrl"). %%-define(DBGFSM, true). diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index df1b9e2f9..a994d1713 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -51,7 +51,6 @@ reply/2, copy_state/2, set_timeout/2, route/2, host_up/1, host_down/1]). --include("ejabberd.hrl"). -include("xmpp.hrl"). -include("logger.hrl"). -include("mod_roster.hrl"). @@ -415,7 +414,7 @@ bind(R, #{user := U, server := S, access := Access, lang := Lang, handle_stream_start(StreamStart, #{lserver := LServer} = State) -> case ejabberd_router:is_my_host(LServer) of false -> - send(State#{lserver => ?MYNAME}, xmpp:serr_host_unknown()); + send(State#{lserver => ejabberd_config:get_myname()}, xmpp:serr_host_unknown()); true -> State1 = change_shaper(State), Opts = ejabberd_config:codec_options(LServer), @@ -526,9 +525,9 @@ init([State, Opts]) -> tls_verify => TLSVerify, pres_a => ?SETS:new(), zlib => Zlib, - lang => ?MYLANG, - server => ?MYNAME, - lserver => ?MYNAME, + lang => ejabberd_config:get_mylang(), + server => ejabberd_config:get_myname(), + lserver => ejabberd_config:get_myname(), access => Access, shaper => Shaper}, State2 = xmpp_stream_in:set_timeout(State1, Timeout), @@ -1041,7 +1040,7 @@ listen_opt_type(backlog) -> listen_opt_type(accept_interval) -> fun(I) when is_integer(I), I>=0 -> I end; listen_opt_type(O) -> - StreamOpts = mod_stream_mgmt:mod_options(?MYNAME), + StreamOpts = mod_stream_mgmt:mod_options(ejabberd_config:get_myname()), case lists:keyfind(O, 1, StreamOpts) of false -> [access, shaper, certfile, ciphers, dhfile, cafile, diff --git a/src/ejabberd_captcha.erl b/src/ejabberd_captcha.erl index a70ad1241..1d3e99c52 100644 --- a/src/ejabberd_captcha.erl +++ b/src/ejabberd_captcha.erl @@ -45,7 +45,6 @@ config_reloaded/0, process_iq/1]). -include("xmpp.hrl"). --include("ejabberd.hrl"). -include("logger.hrl"). -include("ejabberd_http.hrl"). @@ -365,12 +364,12 @@ terminate(_Reason, #state{enabled = Enabled}) -> register_handlers() -> ejabberd_hooks:add(host_up, ?MODULE, host_up, 50), ejabberd_hooks:add(host_down, ?MODULE, host_down, 50), - lists:foreach(fun host_up/1, ?MYHOSTS). + lists:foreach(fun host_up/1, ejabberd_config:get_myhosts()). unregister_handlers() -> ejabberd_hooks:delete(host_up, ?MODULE, host_up, 50), ejabberd_hooks:delete(host_down, ?MODULE, host_down, 50), - lists:foreach(fun host_down/1, ?MYHOSTS). + lists:foreach(fun host_down/1, ejabberd_config:get_myhosts()). code_change(_OldVsn, State, _Extra) -> {ok, State}. @@ -445,7 +444,7 @@ get_url(Str) -> <>; _ -> - <<"http://", (?MYNAME)/binary, "/captcha/", Str/binary>> + <<"http://", (ejabberd_config:get_myname())/binary, "/captcha/", Str/binary>> end. get_transfer_protocol(PortString) -> diff --git a/src/ejabberd_cluster_mnesia.erl b/src/ejabberd_cluster_mnesia.erl index 670dcd19a..4889abd66 100644 --- a/src/ejabberd_cluster_mnesia.erl +++ b/src/ejabberd_cluster_mnesia.erl @@ -31,7 +31,6 @@ get_known_nodes/0, node_id/0, get_node_by_id/1, send/2, wait_for_sync/1, subscribe/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -spec init() -> ok. diff --git a/src/ejabberd_commands.erl b/src/ejabberd_commands.erl index d9523ace5..7a3bd98d0 100644 --- a/src/ejabberd_commands.erl +++ b/src/ejabberd_commands.erl @@ -240,7 +240,6 @@ terminate/2, code_change/3]). -include("ejabberd_commands.hrl"). --include("ejabberd.hrl"). -include("logger.hrl"). -include_lib("stdlib/include/ms_transform.hrl"). diff --git a/src/ejabberd_commands_doc.erl b/src/ejabberd_commands_doc.erl index a15bfd157..fb507a61e 100644 --- a/src/ejabberd_commands_doc.erl +++ b/src/ejabberd_commands_doc.erl @@ -30,7 +30,6 @@ -export([generate_md_output/3]). -include("ejabberd_commands.hrl"). --include("ejabberd.hrl"). -define(RAW(V), if HTMLOutput -> fxml:crypt(iolist_to_binary(V)); true -> iolist_to_binary(V) end). -define(TAG(N), if HTMLOutput -> [<<"<", ??N, "/>">>]; true -> md_tag(N, <<"">>) end). diff --git a/src/ejabberd_config.erl b/src/ejabberd_config.erl index 9e195813e..a2adde8f6 100644 --- a/src/ejabberd_config.erl +++ b/src/ejabberd_config.erl @@ -28,7 +28,8 @@ -export([start/0, load_file/1, reload_file/0, read_file/1, get_option/1, get_option/2, add_option/2, has_option/1, - get_version/0, get_myhosts/0, get_mylang/0, get_lang/1, + get_version/0, get_myhosts/0, get_myname/0, + get_mylang/0, get_lang/1, get_uri/0, get_copyright/0, get_ejabberd_config_path/0, is_using_elixir_config/0, prepare_opt_val/4, transform_options/1, collect_options/1, convert_to_yaml/1, convert_to_yaml/2, v_db/2, @@ -53,7 +54,6 @@ {get_global_option, 3}, {get_local_option, 3}, {get_option, 3}, {is_file_readable, 1}]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("ejabberd_config.hrl"). -include_lib("kernel/include/file.hrl"). @@ -136,7 +136,7 @@ get_ejabberd_config_path() -> undefined -> case os:getenv("EJABBERD_CONFIG_PATH") of false -> - ?CONFIG_PATH; + "ejabberd.yml"; Path -> Path end @@ -1087,6 +1087,11 @@ get_version() -> get_myhosts() -> get_option(hosts). +-spec get_myname() -> binary(). + +get_myname() -> + hd(get_myhosts()). + -spec get_mylang() -> binary(). get_mylang() -> @@ -1096,6 +1101,14 @@ get_mylang() -> get_lang(Host) -> get_option({language, Host}, <<"en">>). +-spec get_uri() -> binary(). +get_uri() -> + <<"http://www.process-one.net/en/ejabberd/">>. + +-spec get_copyright() -> binary(). +get_copyright() -> + <<"Copyright (c) ProcessOne">>. + replace_module(mod_announce_odbc) -> {mod_announce, sql}; replace_module(mod_blocking_odbc) -> {mod_blocking, sql}; replace_module(mod_caps_odbc) -> {mod_caps, sql}; diff --git a/src/ejabberd_ctl.erl b/src/ejabberd_ctl.erl index 408e489e6..a1a92f3e2 100644 --- a/src/ejabberd_ctl.erl +++ b/src/ejabberd_ctl.erl @@ -58,7 +58,6 @@ -include("ejabberd_ctl.hrl"). -include("ejabberd_commands.hrl"). --include("ejabberd.hrl"). -include("logger.hrl"). -define(DEFAULT_VERSION, 1000000). diff --git a/src/ejabberd_http.erl b/src/ejabberd_http.erl index 7afe1ce55..ef1888b12 100644 --- a/src/ejabberd_http.erl +++ b/src/ejabberd_http.erl @@ -36,7 +36,6 @@ -export([init/2, opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("ejabberd_http.hrl"). @@ -787,7 +786,8 @@ rest_dir(N, Path, <<_H, T/binary>>) -> rest_dir(N, Path, T). expand_custom_headers(Headers) -> lists:map(fun({K, V}) -> - {K, misc:expand_keyword(<<"@VERSION@">>, V, ?VERSION)} + {K, misc:expand_keyword(<<"@VERSION@">>, V, + ejabberd_config:get_version())} end, Headers). code_to_phrase(100) -> <<"Continue">>; @@ -917,11 +917,11 @@ get_certfile(Opts) -> {_, CertFile} -> CertFile; false -> - case ejabberd_pkix:get_certfile(?MYNAME) of + case ejabberd_pkix:get_certfile(ejabberd_config:get_myname()) of {ok, CertFile} -> CertFile; error -> - ejabberd_config:get_option({domain_certfile, ?MYNAME}) + ejabberd_config:get_option({domain_certfile, ejabberd_config:get_myname()}) end end. diff --git a/src/ejabberd_http_ws.erl b/src/ejabberd_http_ws.erl index b989f3077..669041c66 100644 --- a/src/ejabberd_http_ws.erl +++ b/src/ejabberd_http_ws.erl @@ -37,7 +37,6 @@ monitor/1, reset_stream/1, close/1, change_shaper/2, socket_handoff/3, opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). @@ -138,10 +137,10 @@ init([{#ws{ip = IP, http_opts = HOpts}, _} = WS]) -> end, HOpts), Opts = ejabberd_c2s_config:get_c2s_limits() ++ SOpts, PingInterval = ejabberd_config:get_option( - {websocket_ping_interval, ?MYNAME}, + {websocket_ping_interval, ejabberd_config:get_myname()}, ?PING_INTERVAL) * 1000, WSTimeout = ejabberd_config:get_option( - {websocket_timeout, ?MYNAME}, + {websocket_timeout, ejabberd_config:get_myname()}, ?WEBSOCKET_TIMEOUT) * 1000, Socket = {http_ws, self(), IP}, ?DEBUG("Client connected through websocket ~p", diff --git a/src/ejabberd_listener.erl b/src/ejabberd_listener.erl index 68a41e33b..f5a65183a 100644 --- a/src/ejabberd_listener.erl +++ b/src/ejabberd_listener.erl @@ -34,7 +34,6 @@ add_listener/3, delete_listener/2, transform_options/1, validate_cfg/1, opt_type/1, config_reloaded/0]). --include("ejabberd.hrl"). -include("logger.hrl"). %% We do not block on send anymore. diff --git a/src/ejabberd_local.erl b/src/ejabberd_local.erl index 9f250fab3..37087526b 100644 --- a/src/ejabberd_local.erl +++ b/src/ejabberd_local.erl @@ -45,7 +45,6 @@ -export([route_iq/2, route_iq/3]). -deprecated([{route_iq, 2}, {route_iq, 3}]). --include("ejabberd.hrl"). -include("logger.hrl"). -include_lib("stdlib/include/ms_transform.hrl"). -include("xmpp.hrl"). @@ -106,7 +105,7 @@ get_features(Host) -> init([]) -> process_flag(trap_exit, true), - lists:foreach(fun host_up/1, ?MYHOSTS), + lists:foreach(fun host_up/1, ejabberd_config:get_myhosts()), ejabberd_hooks:add(host_up, ?MODULE, host_up, 10), ejabberd_hooks:add(host_down, ?MODULE, host_down, 100), gen_iq_handler:start(?MODULE), @@ -126,7 +125,7 @@ handle_info(Info, State) -> {noreply, State}. terminate(_Reason, _State) -> - lists:foreach(fun host_down/1, ?MYHOSTS), + lists:foreach(fun host_down/1, ejabberd_config:get_myhosts()), ejabberd_hooks:delete(host_up, ?MODULE, host_up, 10), ejabberd_hooks:delete(host_down, ?MODULE, host_down, 100), ok. diff --git a/src/ejabberd_logger.erl b/src/ejabberd_logger.erl index f28b607d5..fecd9485c 100644 --- a/src/ejabberd_logger.erl +++ b/src/ejabberd_logger.erl @@ -30,7 +30,6 @@ -export([start/0, restart/0, reopen_log/0, rotate_log/0, get/0, set/1, get_log_path/0, opt_type/1]). --include("ejabberd.hrl"). -type loglevel() :: 0 | 1 | 2 | 3 | 4 | 5. @@ -59,7 +58,7 @@ get_log_path() -> undefined -> case os:getenv("EJABBERD_LOG_PATH") of false -> - ?LOG_PATH; + "ejabberd.log"; Path -> Path end diff --git a/src/ejabberd_oauth.erl b/src/ejabberd_oauth.erl index 8a1bf39bd..d7a86d127 100644 --- a/src/ejabberd_oauth.erl +++ b/src/ejabberd_oauth.erl @@ -54,7 +54,6 @@ -include("xmpp.hrl"). --include("ejabberd.hrl"). -include("logger.hrl"). -include("ejabberd_http.hrl"). diff --git a/src/ejabberd_oauth_rest.erl b/src/ejabberd_oauth_rest.erl index 28d291484..6e2e92218 100644 --- a/src/ejabberd_oauth_rest.erl +++ b/src/ejabberd_oauth_rest.erl @@ -34,13 +34,12 @@ clean/1, opt_type/1]). --include("ejabberd.hrl"). -include("ejabberd_oauth.hrl"). -include("logger.hrl"). -include("jid.hrl"). init() -> - rest:start(?MYNAME), + rest:start(ejabberd_config:get_myname()), ok. store(R) -> @@ -50,7 +49,7 @@ store(R) -> SJID = jid:encode({User, Server, <<"">>}), case rest:with_retry( post, - [?MYNAME, Path, [], + [ejabberd_config:get_myname(), Path, [], {[{<<"token">>, R#oauth_token.token}, {<<"user">>, SJID}, {<<"scope">>, R#oauth_token.scope}, @@ -65,7 +64,7 @@ store(R) -> lookup(Token) -> Path = path(<<"lookup">>), - case rest:with_retry(post, [?MYNAME, Path, [], + case rest:with_retry(post, [ejabberd_config:get_myname(), Path, [], {[{<<"token">>, Token}]}], 2, 500) of {ok, 200, {Data}} -> diff --git a/src/ejabberd_oauth_sql.erl b/src/ejabberd_oauth_sql.erl index 503315eca..f8daa51bd 100644 --- a/src/ejabberd_oauth_sql.erl +++ b/src/ejabberd_oauth_sql.erl @@ -34,7 +34,6 @@ clean/1]). -include("ejabberd_oauth.hrl"). --include("ejabberd.hrl"). -include("ejabberd_sql_pt.hrl"). -include("jid.hrl"). -include("logger.hrl"). @@ -49,7 +48,7 @@ store(R) -> Scope = str:join(R#oauth_token.scope, <<" ">>), Expire = R#oauth_token.expire, case ?SQL_UPSERT( - ?MYNAME, + ejabberd_config:get_myname(), "oauth_token", ["!token=%(Token)s", "jid=%(SJID)s", @@ -63,7 +62,7 @@ store(R) -> lookup(Token) -> case ejabberd_sql:sql_query( - ?MYNAME, + ejabberd_config:get_myname(), ?SQL("select @(jid)s, @(scope)s, @(expire)d" " from oauth_token where token=%(Token)s")) of {selected, [{SJID, Scope, Expire}]} -> @@ -79,6 +78,6 @@ lookup(Token) -> clean(TS) -> ejabberd_sql:sql_query( - ?MYNAME, + ejabberd_config:get_myname(), ?SQL("delete from oauth_token where expire < %(TS)d")). diff --git a/src/ejabberd_piefxis.erl b/src/ejabberd_piefxis.erl index afb0e1a05..20d84b405 100644 --- a/src/ejabberd_piefxis.erl +++ b/src/ejabberd_piefxis.erl @@ -40,7 +40,7 @@ -define(CHUNK_SIZE, 1024*20). %20k --include("ejabberd.hrl"). +-include("scram.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("mod_privacy.hrl"). @@ -92,7 +92,7 @@ import_file(FileName, State) -> -spec export_server(binary()) -> any(). export_server(Dir) -> - export_hosts(?MYHOSTS, Dir). + export_hosts(ejabberd_config:get_myhosts(), Dir). -spec export_host(binary(), binary()) -> any(). export_host(Dir, Host) -> diff --git a/src/ejabberd_rdbms.erl b/src/ejabberd_rdbms.erl index 6f4a7b770..af3950f03 100644 --- a/src/ejabberd_rdbms.erl +++ b/src/ejabberd_rdbms.erl @@ -33,7 +33,6 @@ -export([start_link/0, init/1, opt_type/1, config_reloaded/0, start_host/1, stop_host/1]). --include("ejabberd.hrl"). -include("logger.hrl"). start_link() -> @@ -56,7 +55,7 @@ get_specs() -> {ok, Spec} -> [Spec]; undefined -> [] end - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). -spec get_spec(binary()) -> {ok, supervisor:child_spec()} | undefined. get_spec(Host) -> @@ -72,7 +71,7 @@ get_spec(Host) -> -spec config_reloaded() -> ok. config_reloaded() -> - lists:foreach(fun start_host/1, ?MYHOSTS). + lists:foreach(fun start_host/1, ejabberd_config:get_myhosts()). -spec start_host(binary()) -> ok. start_host(Host) -> diff --git a/src/ejabberd_redis.erl b/src/ejabberd_redis.erl index 672449b52..23415cbfd 100644 --- a/src/ejabberd_redis.erl +++ b/src/ejabberd_redis.erl @@ -50,7 +50,6 @@ -define(CALL_TIMEOUT, 60*1000). %% 60 seconds -include("logger.hrl"). --include("ejabberd.hrl"). -record(state, {connection :: pid() | undefined, num :: pos_integer(), diff --git a/src/ejabberd_redis_sup.erl b/src/ejabberd_redis_sup.erl index 685fad9e1..f3dfb7e06 100644 --- a/src/ejabberd_redis_sup.erl +++ b/src/ejabberd_redis_sup.erl @@ -32,7 +32,6 @@ %% Supervisor callbacks -export([init/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -define(DEFAULT_POOL_SIZE, 10). @@ -98,7 +97,7 @@ init([]) -> %%% Internal functions %%%=================================================================== is_redis_configured() -> - lists:any(fun is_redis_configured/1, ?MYHOSTS). + lists:any(fun is_redis_configured/1, ejabberd_config:get_myhosts()). is_redis_configured(Host) -> ServerConfigured = ejabberd_config:has_option({redis_server, Host}), diff --git a/src/ejabberd_riak.erl b/src/ejabberd_riak.erl index d2c3d9d0b..54c84d543 100644 --- a/src/ejabberd_riak.erl +++ b/src/ejabberd_riak.erl @@ -41,7 +41,6 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --include("ejabberd.hrl"). -include("logger.hrl"). -record(state, {pid = self() :: pid()}). diff --git a/src/ejabberd_riak_sup.erl b/src/ejabberd_riak_sup.erl index d5a66e31f..fb5d10043 100644 --- a/src/ejabberd_riak_sup.erl +++ b/src/ejabberd_riak_sup.erl @@ -33,7 +33,6 @@ transform_options/1, get_random_pid/0, host_up/1, config_reloaded/0, opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -define(DEFAULT_POOL_SIZE, 10). @@ -74,7 +73,7 @@ config_reloaded() -> end. is_riak_configured() -> - lists:any(fun is_riak_configured/1, ?MYHOSTS). + lists:any(fun is_riak_configured/1, ejabberd_config:get_myhosts()). is_riak_configured(Host) -> ServerConfigured = ejabberd_config:has_option({riak_server, Host}), diff --git a/src/ejabberd_router.erl b/src/ejabberd_router.erl index f49e94194..b668f2b37 100644 --- a/src/ejabberd_router.erl +++ b/src/ejabberd_router.erl @@ -68,7 +68,6 @@ %% This value is used in SIP and Megaco for a transaction lifetime. -define(IQ_TIMEOUT, 32000). --include("ejabberd.hrl"). -include("logger.hrl"). -include("ejabberd_router.hrl"). -include("xmpp.hrl"). diff --git a/src/ejabberd_router_mnesia.erl b/src/ejabberd_router_mnesia.erl index acf21a160..a97874bcd 100644 --- a/src/ejabberd_router_mnesia.erl +++ b/src/ejabberd_router_mnesia.erl @@ -30,7 +30,6 @@ -export([init/1, handle_cast/2, handle_call/3, handle_info/2, terminate/2, code_change/3, start_link/0]). --include("ejabberd.hrl"). -include("ejabberd_router.hrl"). -include("logger.hrl"). -include_lib("stdlib/include/ms_transform.hrl"). diff --git a/src/ejabberd_router_multicast.erl b/src/ejabberd_router_multicast.erl index 37f3d245d..c95c18882 100644 --- a/src/ejabberd_router_multicast.erl +++ b/src/ejabberd_router_multicast.erl @@ -41,7 +41,6 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/ejabberd_router_redis.erl b/src/ejabberd_router_redis.erl index 668e3e064..706a6b4fe 100644 --- a/src/ejabberd_router_redis.erl +++ b/src/ejabberd_router_redis.erl @@ -31,7 +31,6 @@ -export([init/1, handle_cast/2, handle_call/3, handle_info/2, terminate/2, code_change/3, start_link/0]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("ejabberd_router.hrl"). diff --git a/src/ejabberd_router_sql.erl b/src/ejabberd_router_sql.erl index 3c984afd1..b7017d528 100644 --- a/src/ejabberd_router_sql.erl +++ b/src/ejabberd_router_sql.erl @@ -29,7 +29,6 @@ -export([init/0, register_route/5, unregister_route/3, find_routes/1, get_all_routes/0]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("ejabberd_sql_pt.hrl"). -include("ejabberd_router.hrl"). @@ -41,7 +40,7 @@ init() -> Node = erlang:atom_to_binary(node(), latin1), ?DEBUG("Cleaning SQL 'route' table...", []), case ejabberd_sql:sql_query( - ?MYNAME, ?SQL("delete from route where node=%(Node)s")) of + ejabberd_config:get_myname(), ?SQL("delete from route where node=%(Node)s")) of {updated, _} -> ok; Err -> @@ -53,7 +52,7 @@ register_route(Domain, ServerHost, LocalHint, _, Pid) -> PidS = misc:encode_pid(Pid), LocalHintS = enc_local_hint(LocalHint), Node = erlang:atom_to_binary(node(Pid), latin1), - case ?SQL_UPSERT(?MYNAME, "route", + case ?SQL_UPSERT(ejabberd_config:get_myname(), "route", ["!domain=%(Domain)s", "!server_host=%(ServerHost)s", "!node=%(Node)s", @@ -69,7 +68,7 @@ unregister_route(Domain, _, Pid) -> PidS = misc:encode_pid(Pid), Node = erlang:atom_to_binary(node(Pid), latin1), case ejabberd_sql:sql_query( - ?MYNAME, + ejabberd_config:get_myname(), ?SQL("delete from route where domain=%(Domain)s " "and pid=%(PidS)s and node=%(Node)s")) of {updated, _} -> @@ -80,7 +79,7 @@ unregister_route(Domain, _, Pid) -> find_routes(Domain) -> case ejabberd_sql:sql_query( - ?MYNAME, + ejabberd_config:get_myname(), ?SQL("select @(server_host)s, @(node)s, @(pid)s, @(local_hint)s " "from route where domain=%(Domain)s")) of {selected, Rows} -> @@ -94,7 +93,7 @@ find_routes(Domain) -> get_all_routes() -> case ejabberd_sql:sql_query( - ?MYNAME, + ejabberd_config:get_myname(), ?SQL("select @(domain)s from route where domain <> server_host")) of {selected, Domains} -> {ok, [Domain || {Domain} <- Domains]}; diff --git a/src/ejabberd_s2s.erl b/src/ejabberd_s2s.erl index 6036cc177..7b043d125 100644 --- a/src/ejabberd_s2s.erl +++ b/src/ejabberd_s2s.erl @@ -54,7 +54,6 @@ -export([get_info_s2s_connections/1, transform_options/1, opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). @@ -303,7 +302,7 @@ init([]) -> {attributes, record_info(fields, temporarily_blocked)}]), ejabberd_hooks:add(host_up, ?MODULE, host_up, 50), ejabberd_hooks:add(host_down, ?MODULE, host_down, 60), - lists:foreach(fun host_up/1, ?MYHOSTS), + lists:foreach(fun host_up/1, ejabberd_config:get_myhosts()), {ok, #state{}}. handle_call(_Request, _From, State) -> @@ -322,7 +321,7 @@ handle_info(_Info, State) -> {noreply, State}. terminate(_Reason, _State) -> ejabberd_commands:unregister_commands(get_commands_spec()), - lists:foreach(fun host_down/1, ?MYHOSTS), + lists:foreach(fun host_down/1, ejabberd_config:get_myhosts()), ejabberd_hooks:delete(host_up, ?MODULE, host_up, 50), ejabberd_hooks:delete(host_down, ?MODULE, host_down, 60), ok. @@ -544,7 +543,7 @@ is_service(From, To) -> s2s -> % bypass RFC 3920 10.3 false; local -> - Hosts = (?MYHOSTS), + Hosts = ejabberd_config:get_myhosts(), P = fun (ParentDomain) -> lists:member(ParentDomain, Hosts) end, diff --git a/src/ejabberd_s2s_in.erl b/src/ejabberd_s2s_in.erl index bf4afb5b5..7a6bc46e5 100644 --- a/src/ejabberd_s2s_in.erl +++ b/src/ejabberd_s2s_in.erl @@ -44,7 +44,6 @@ -export([stop/1, close/1, close/2, send/2, update_state/2, establish/1, host_up/1, host_down/1]). --include("ejabberd.hrl"). -include("xmpp.hrl"). -include("logger.hrl"). @@ -263,10 +262,10 @@ init([State, Opts]) -> State1 = State#{tls_options => TLSOpts2, auth_domains => sets:new(), xmlns => ?NS_SERVER, - lang => ?MYLANG, - server => ?MYNAME, - lserver => ?MYNAME, - server_host => ?MYNAME, + lang => ejabberd_config:get_mylang(), + server => ejabberd_config:get_myname(), + lserver => ejabberd_config:get_myname(), + server_host => ejabberd_config:get_myname(), established => false, shaper => Shaper}, State2 = xmpp_stream_in:set_timeout(State1, Timeout), diff --git a/src/ejabberd_s2s_out.erl b/src/ejabberd_s2s_out.erl index f82d017ea..765c00d65 100644 --- a/src/ejabberd_s2s_out.erl +++ b/src/ejabberd_s2s_out.erl @@ -42,7 +42,6 @@ -export([start/3, start_link/3, connect/1, close/1, close/2, stop/1, send/2, route/2, establish/1, update_state/2, host_up/1, host_down/1]). --include("ejabberd.hrl"). -include("xmpp.hrl"). -include("logger.hrl"). @@ -274,7 +273,7 @@ init([#{server := LServer, remote_server := RServer} = State, Opts]) -> State1 = State#{on_route => queue, queue => p1_queue:new(QueueType, QueueLimit), xmlns => ?NS_SERVER, - lang => ?MYLANG, + lang => ejabberd_config:get_mylang(), server_host => ServerHost, shaper => none}, State2 = xmpp_stream_out:set_timeout(State1, Timeout), diff --git a/src/ejabberd_service.erl b/src/ejabberd_service.erl index 4c3ae16a3..be417ff9c 100644 --- a/src/ejabberd_service.erl +++ b/src/ejabberd_service.erl @@ -36,7 +36,6 @@ %% API -export([send/2]). --include("ejabberd.hrl"). -include("xmpp.hrl"). -include("logger.hrl"). @@ -106,8 +105,8 @@ init([State, Opts]) -> State2 = xmpp_stream_in:set_timeout(State1, Timeout), State3 = State2#{access => Access, xmlns => ?NS_COMPONENT, - lang => ?MYLANG, - server => ?MYNAME, + lang => ejabberd_config:get_mylang(), + server => ejabberd_config:get_myname(), host_opts => dict:from_list(HostOpts1), stream_version => undefined, tls_options => TLSOpts, @@ -170,7 +169,7 @@ handle_auth_success(_, Mech, _, end, lists:foreach( fun(H) -> - ejabberd_router:register_route(H, ?MYNAME), + ejabberd_router:register_route(H, ejabberd_config:get_myname()), ejabberd_hooks:run(component_connected, [H]) end, Routes), State. diff --git a/src/ejabberd_sip.erl b/src/ejabberd_sip.erl index 4606d768c..e49fb4841 100644 --- a/src/ejabberd_sip.erl +++ b/src/ejabberd_sip.erl @@ -44,7 +44,6 @@ start(_, _) -> -export([tcp_init/2, udp_init/2, udp_recv/5, start/2, socket_type/0, listen_opt_type/1]). --include("ejabberd.hrl"). %%%=================================================================== %%% API @@ -71,11 +70,11 @@ set_certfile(Opts) -> true -> Opts; false -> - case ejabberd_pkix:get_certfile(?MYNAME) of + case ejabberd_pkix:get_certfile(ejabberd_config:get_myname()) of {ok, CertFile} -> [{certfile, CertFile}|Opts]; error -> - case ejabberd_config:get_option({domain_certfile, ?MYNAME}) of + case ejabberd_config:get_option({domain_certfile, ejabberd_config:get_myname()}) of undefined -> Opts; CertFile -> diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index 67fa8ca00..ef6a62979 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -85,7 +85,6 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3, opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). @@ -428,7 +427,7 @@ init([]) -> ejabberd_hooks:add(host_up, ?MODULE, host_up, 50), ejabberd_hooks:add(host_down, ?MODULE, host_down, 60), ejabberd_hooks:add(config_reloaded, ?MODULE, config_reloaded, 50), - lists:foreach(fun host_up/1, ?MYHOSTS), + lists:foreach(fun host_up/1, ejabberd_config:get_myhosts()), ejabberd_commands:register_commands(get_commands_spec()), {ok, #state{}}. @@ -445,7 +444,7 @@ handle_info(Info, State) -> {noreply, State}. terminate(_Reason, _State) -> - lists:foreach(fun host_down/1, ?MYHOSTS), + lists:foreach(fun host_down/1, ejabberd_config:get_myhosts()), ejabberd_hooks:delete(host_up, ?MODULE, host_up, 50), ejabberd_hooks:delete(host_down, ?MODULE, host_down, 60), ejabberd_hooks:delete(config_reloaded, ?MODULE, config_reloaded, 50), @@ -848,7 +847,7 @@ get_sm_backend(Host) -> -spec get_sm_backends() -> [module()]. get_sm_backends() -> - lists:usort([get_sm_backend(Host) || Host <- ?MYHOSTS]). + lists:usort([get_sm_backend(Host) || Host <- ejabberd_config:get_myhosts()]). -spec get_vh_by_backend(module()) -> [binary()]. @@ -856,7 +855,7 @@ get_vh_by_backend(Mod) -> lists:filter( fun(Host) -> get_sm_backend(Host) == Mod - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). %%-------------------------------------------------------------------- %%% Cache stuff @@ -919,7 +918,7 @@ use_cache() -> fun(Host) -> Mod = get_sm_backend(Host), use_cache(Mod, Host) - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). -spec cache_nodes(module(), binary()) -> [node()]. cache_nodes(Mod, LServer) -> diff --git a/src/ejabberd_sm_mnesia.erl b/src/ejabberd_sm_mnesia.erl index 8bd38c2fb..43b49202e 100644 --- a/src/ejabberd_sm_mnesia.erl +++ b/src/ejabberd_sm_mnesia.erl @@ -40,7 +40,6 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3, start_link/0]). --include("ejabberd.hrl"). -include("ejabberd_sm.hrl"). -include_lib("stdlib/include/ms_transform.hrl"). diff --git a/src/ejabberd_sm_redis.erl b/src/ejabberd_sm_redis.erl index 3e9b354ee..340b2cb65 100644 --- a/src/ejabberd_sm_redis.erl +++ b/src/ejabberd_sm_redis.erl @@ -37,7 +37,6 @@ -export([init/1, handle_cast/2, handle_call/3, handle_info/2, terminate/2, code_change/3, start_link/0]). --include("ejabberd.hrl"). -include("ejabberd_sm.hrl"). -include("logger.hrl"). diff --git a/src/ejabberd_sm_sql.erl b/src/ejabberd_sm_sql.erl index aba917caf..a14cebd4f 100644 --- a/src/ejabberd_sm_sql.erl +++ b/src/ejabberd_sm_sql.erl @@ -36,7 +36,6 @@ get_sessions/1, get_sessions/2]). --include("ejabberd.hrl"). -include("ejabberd_sm.hrl"). -include("logger.hrl"). -include("ejabberd_sql_pt.hrl"). diff --git a/src/ejabberd_sql.erl b/src/ejabberd_sql.erl index 675941aea..28103430a 100644 --- a/src/ejabberd_sql.erl +++ b/src/ejabberd_sql.erl @@ -66,7 +66,6 @@ session_established/2, session_established/3, opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("ejabberd_sql_pt.hrl"). diff --git a/src/ejabberd_sql_sup.erl b/src/ejabberd_sql_sup.erl index 8b3ee6f01..0827b6492 100644 --- a/src/ejabberd_sql_sup.erl +++ b/src/ejabberd_sql_sup.erl @@ -33,7 +33,6 @@ get_pids/1, get_random_pid/1, transform_options/1, opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -define(PGSQL_PORT, 5432). @@ -172,12 +171,7 @@ check_sqlite_db(Host) -> end. create_sqlite_tables(DB) -> - SqlDir = case code:priv_dir(ejabberd) of - {error, _} -> - ?SQL_DIR; - PrivDir -> - filename:join(PrivDir, "sql") - end, + SqlDir = misc:sql_dir(), File = filename:join(SqlDir, "lite.sql"), case file:open(File, [read, binary]) of {ok, Fd} -> diff --git a/src/ejabberd_stun.erl b/src/ejabberd_stun.erl index 1ba16d548..8aae66221 100644 --- a/src/ejabberd_stun.erl +++ b/src/ejabberd_stun.erl @@ -46,7 +46,6 @@ start(_, _) -> -export([tcp_init/2, udp_init/2, udp_recv/5, start/2, socket_type/0, listen_opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). %%%=================================================================== @@ -79,7 +78,7 @@ prepare_turn_opts(Opts) -> prepare_turn_opts(Opts, _UseTurn = false) -> set_certfile(Opts); prepare_turn_opts(Opts, _UseTurn = true) -> - NumberOfMyHosts = length(?MYHOSTS), + NumberOfMyHosts = length(ejabberd_config:get_myhosts()), case proplists:get_value(turn_ip, Opts) of undefined -> ?WARNING_MSG("option 'turn_ip' is undefined, " @@ -100,11 +99,11 @@ prepare_turn_opts(Opts, _UseTurn = true) -> "'auth_type' is set to 'user', " "more likely the TURN relay won't " "be working properly. Using ~s as " - "a fallback", [?MYNAME]); + "a fallback", [ejabberd_config:get_myname()]); true -> ok end, - [{auth_realm, ?MYNAME}]; + [{auth_realm, ejabberd_config:get_myname()}]; _ -> [] end, @@ -118,7 +117,7 @@ set_certfile(Opts) -> true -> Opts; false -> - Realm = proplists:get_value(auth_realm, Opts, ?MYNAME), + Realm = proplists:get_value(auth_realm, Opts, ejabberd_config:get_myname()), case ejabberd_pkix:get_certfile(Realm) of {ok, CertFile} -> [{certfile, CertFile}|Opts]; diff --git a/src/ejabberd_update.erl b/src/ejabberd_update.erl index debf4911d..4c360011f 100644 --- a/src/ejabberd_update.erl +++ b/src/ejabberd_update.erl @@ -29,7 +29,6 @@ %% API -export([update/0, update/1, update_info/0]). --include("ejabberd.hrl"). -include("logger.hrl"). %%==================================================================== diff --git a/src/ejabberd_web.erl b/src/ejabberd_web.erl index c2a4ab193..a0291fc6f 100644 --- a/src/ejabberd_web.erl +++ b/src/ejabberd_web.erl @@ -31,7 +31,6 @@ %% External exports -export([make_xhtml/1, make_xhtml/2, error/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/ejabberd_web_admin.erl b/src/ejabberd_web_admin.erl index 524c80f50..7f031dce0 100644 --- a/src/ejabberd_web_admin.erl +++ b/src/ejabberd_web_admin.erl @@ -35,7 +35,6 @@ list_users_in_diapason/4, pretty_print_xml/1, term_to_id/1, opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). @@ -1062,7 +1061,7 @@ parse_access_rule(Text) -> %%%% list_vhosts list_vhosts(Lang, JID) -> - Hosts = (?MYHOSTS), + Hosts = ejabberd_config:get_myhosts(), HostsAllowed = lists:filter(fun (Host) -> acl:any_rules_allowed(Host, [configure, webadmin_view], @@ -1282,7 +1281,7 @@ get_stats(global, Lang) -> ejabberd_auth:count_users(Host) + Total end, - 0, ?MYHOSTS), + 0, ejabberd_config:get_myhosts()), OutS2SNumber = ejabberd_s2s:outgoing_s2s_number(), InS2SNumber = ejabberd_s2s:incoming_s2s_number(), [?XAE(<<"table">>, [], @@ -1784,7 +1783,7 @@ get_node(global, Node, [<<"backup">>], Query, Lang) -> ?C(<<" ">>), ?INPUT(<<"text">>, <<"export_piefxis_host_dirhost">>, - (?MYNAME))]), + (ejabberd_config:get_myname()))]), ?XE(<<"td">>, [?INPUT(<<"text">>, <<"export_piefxis_host_dirpath">>, @@ -1800,7 +1799,7 @@ get_node(global, Node, [<<"backup">>], Query, Lang) -> ?C(<<" ">>), ?INPUT(<<"text">>, <<"export_sql_filehost">>, - (?MYNAME))]), + (ejabberd_config:get_myname()))]), ?XE(<<"td">>, [?INPUT(<<"text">>, <<"export_sql_filepath">>, diff --git a/src/ejabberd_websocket.erl b/src/ejabberd_websocket.erl index c7d6181f8..5a329797b 100644 --- a/src/ejabberd_websocket.erl +++ b/src/ejabberd_websocket.erl @@ -44,7 +44,6 @@ -export([check/2, socket_handoff/5]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/ejabberd_xmlrpc.erl b/src/ejabberd_xmlrpc.erl index 6860f8cda..68a774d4b 100644 --- a/src/ejabberd_xmlrpc.erl +++ b/src/ejabberd_xmlrpc.erl @@ -37,7 +37,6 @@ -export([start/2, handler/2, process/2, socket_type/0, transform_listen_option/2, listen_opt_type/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("ejabberd_http.hrl"). -include("mod_roster.hrl"). diff --git a/src/eldap.erl b/src/eldap.erl index b086a3e8b..1f2926f4d 100644 --- a/src/eldap.erl +++ b/src/eldap.erl @@ -65,7 +65,7 @@ -behaviour(p1_fsm). --include("ejabberd.hrl"). +-include("type_compat.hrl"). -include("logger.hrl"). %% External exports diff --git a/src/eldap_pool.erl b/src/eldap_pool.erl index da576da1b..647ff02e2 100644 --- a/src/eldap_pool.erl +++ b/src/eldap_pool.erl @@ -31,7 +31,6 @@ -export([start_link/7, bind/3, search/2, modify_passwd/3]). --include("ejabberd.hrl"). -include("logger.hrl"). %%==================================================================== diff --git a/src/eldap_utils.erl b/src/eldap_utils.erl index 0a0d3f965..ce642a779 100644 --- a/src/eldap_utils.erl +++ b/src/eldap_utils.erl @@ -34,7 +34,6 @@ decode_octet_string/3, uids_domain_subst/2, opt_type/1, options/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("eldap.hrl"). diff --git a/src/gen_iq_handler.erl b/src/gen_iq_handler.erl index 15155ac1a..9568b1ccd 100644 --- a/src/gen_iq_handler.erl +++ b/src/gen_iq_handler.erl @@ -37,7 +37,6 @@ -export([add_iq_handler/6, handle/5, iqdisc/1]). -deprecated([{add_iq_handler, 6}, {handle, 5}, {iqdisc, 1}]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/gen_mod.erl b/src/gen_mod.erl index 878ac41ec..b003986a8 100644 --- a/src/gen_mod.erl +++ b/src/gen_mod.erl @@ -56,7 +56,6 @@ {ram_db_type, 2}, {ram_db_type, 3}]). --include("ejabberd.hrl"). -include("logger.hrl"). -include_lib("stdlib/include/ms_transform.hrl"). @@ -127,7 +126,7 @@ stop_child(Proc) -> %% Start all the modules in all the hosts start_modules() -> - Hosts = ?MYHOSTS, + Hosts = ejabberd_config:get_myhosts(), ?INFO_MSG("Loading modules for ~s", [format_hosts_list(Hosts)]), lists:foreach(fun start_modules/1, Hosts). @@ -327,7 +326,7 @@ stop_modules() -> lists:foreach( fun(Host) -> stop_modules(Host) - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). -spec stop_modules(binary()) -> ok. @@ -418,7 +417,7 @@ get_module_opt(Host, Module, Opt) -> get_module_opt(Host, Module, Opt, F) when is_function(F) -> get_module_opt(Host, Module, Opt, undefined); get_module_opt(global, Module, Opt, Default) -> - Hosts = (?MYHOSTS), + Hosts = ejabberd_config:get_myhosts(), [Value | Values] = lists:map(fun (Host) -> get_module_opt(Host, Module, Opt, Default) @@ -867,7 +866,7 @@ get_hosts(Opts, Prefix) -> undefined -> case get_opt(host, Opts) of undefined -> - [<> || Host <- ?MYHOSTS]; + [<> || Host <- ejabberd_config:get_myhosts()]; Host -> [Host] end; @@ -902,7 +901,7 @@ config_reloaded() -> lists:foreach( fun(Host) -> reload_modules(Host) - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). -spec is_equal_opt(atom(), opts(), opts()) -> true | {false, any(), any()}. diff --git a/src/jd2ejd.erl b/src/jd2ejd.erl index 576763cf9..35ebeab8d 100644 --- a/src/jd2ejd.erl +++ b/src/jd2ejd.erl @@ -30,7 +30,6 @@ %% External exports -export([import_file/1, import_dir/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/jlib.erl b/src/jlib.erl index a4463beee..a0b50cadb 100644 --- a/src/jlib.erl +++ b/src/jlib.erl @@ -131,7 +131,6 @@ {expr_to_term, 1}, {term_to_expr, 1}]). --include("ejabberd.hrl"). -include("jlib.hrl"). %send_iq(From, To, ID, SubTags) -> diff --git a/src/misc.erl b/src/misc.erl index 5904d1e67..9f72ebf88 100644 --- a/src/misc.erl +++ b/src/misc.erl @@ -33,8 +33,9 @@ atom_to_binary/1, binary_to_atom/1, tuple_to_binary/1, l2i/1, i2l/1, i2l/2, expr_to_term/1, term_to_expr/1, now_to_usec/1, usec_to_now/1, encode_pid/1, decode_pid/2, - compile_exprs/2, join_atoms/2, try_read_file/1, - css_dir/0, img_dir/0, js_dir/0, read_css/1, read_img/1, read_js/1]). + compile_exprs/2, join_atoms/2, try_read_file/1, get_descr/2, + css_dir/0, img_dir/0, js_dir/0, msgs_dir/0, sql_dir/0, + read_css/1, read_img/1, read_js/1]). %% Deprecated functions -export([decode_base64/1, encode_base64/1]). @@ -220,36 +221,23 @@ try_read_file(Path) -> -spec css_dir() -> file:filename(). css_dir() -> - case os:getenv("EJABBERD_CSS_PATH") of - false -> - case code:priv_dir(ejabberd) of - {error, _} -> filename:join(["priv", "css"]); - Path -> filename:join([Path, "css"]) - end; - Path -> Path - end. + get_dir("css"). -spec img_dir() -> file:filename(). img_dir() -> - case os:getenv("EJABBERD_IMG_PATH") of - false -> - case code:priv_dir(ejabberd) of - {error, _} -> filename:join(["priv", "img"]); - Path -> filename:join([Path, "img"]) - end; - Path -> Path - end. + get_dir("img"). -spec js_dir() -> file:filename(). js_dir() -> - case os:getenv("EJABBERD_JS_PATH") of - false -> - case code:priv_dir(ejabberd) of - {error, _} -> filename:join(["priv", "js"]); - Path -> filename:join([Path, "js"]) - end; - Path -> Path - end. + get_dir("js"). + +-spec msgs_dir() -> file:filename(). +msgs_dir() -> + get_dir("msgs"). + +-spec sql_dir() -> file:filename(). +sql_dir() -> + get_dir("sql"). -spec read_css(file:filename()) -> {ok, binary()} | {error, file:posix()}. read_css(File) -> @@ -263,6 +251,12 @@ read_img(File) -> read_js(File) -> read_file(filename:join(js_dir(), File)). +-spec get_descr(binary(), binary()) -> binary(). +get_descr(Lang, Text) -> + Desc = translate:translate(Lang, Text), + Copyright = ejabberd_config:get_copyright(), + <>. + %%%=================================================================== %%% Internal functions %%%=================================================================== @@ -304,3 +298,16 @@ read_file(Path) -> [Path, file:format_error(Why)]), Err end. + +-spec get_dir(string()) -> file:filename(). +get_dir(Type) -> + Env = "EJABBERD_" ++ string:to_upper(Type) ++ "_PATH", + case os:getenv(Env) of + false -> + case code:priv_dir(ejabberd) of + {error, _} -> filename:join(["priv", Type]); + Path -> filename:join([Path, Type]) + end; + Path -> + Path + end. diff --git a/src/mod_adhoc.erl b/src/mod_adhoc.erl index f0b889c5d..9071ca817 100644 --- a/src/mod_adhoc.erl +++ b/src/mod_adhoc.erl @@ -38,7 +38,6 @@ ping_item/4, ping_command/4, mod_opt_type/1, depends/2, mod_options/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_admin_extra.erl b/src/mod_admin_extra.erl index 251c09614..6283d2f02 100644 --- a/src/mod_admin_extra.erl +++ b/src/mod_admin_extra.erl @@ -80,7 +80,6 @@ ]). --include("ejabberd.hrl"). -include("ejabberd_commands.hrl"). -include("mod_roster.hrl"). -include("mod_privacy.hrl"). @@ -1594,7 +1593,7 @@ stats(Name) -> case Name of <<"uptimeseconds">> -> trunc(element(1, erlang:statistics(wall_clock))/1000); <<"processes">> -> length(erlang:processes()); - <<"registeredusers">> -> lists:foldl(fun(Host, Sum) -> ejabberd_auth:count_users(Host) + Sum end, 0, ?MYHOSTS); + <<"registeredusers">> -> lists:foldl(fun(Host, Sum) -> ejabberd_auth:count_users(Host) + Sum end, 0, ejabberd_config:get_myhosts()); <<"onlineusersnode">> -> length(ejabberd_sm:dirty_get_my_sessions_list()); <<"onlineusers">> -> length(ejabberd_sm:dirty_get_sessions_list()) end. diff --git a/src/mod_admin_update_sql.erl b/src/mod_admin_update_sql.erl index 0eaab9ff9..51787ff6c 100644 --- a/src/mod_admin_update_sql.erl +++ b/src/mod_admin_update_sql.erl @@ -36,7 +36,6 @@ -include("logger.hrl"). --include("ejabberd.hrl"). -include("ejabberd_commands.hrl"). -include("xmpp.hrl"). -include("ejabberd_sql_pt.hrl"). @@ -82,7 +81,7 @@ update_sql() -> _ -> update_sql(Host) end - end, ?MYHOSTS), + end, ejabberd_config:get_myhosts()), ok. -record(state, {host :: binary(), diff --git a/src/mod_announce.erl b/src/mod_announce.erl index e9da1d9c7..b8ca970c9 100644 --- a/src/mod_announce.erl +++ b/src/mod_announce.erl @@ -50,7 +50,6 @@ announce_motd_delete/1, announce_all_hosts_motd_delete/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("mod_announce.hrl"). @@ -670,7 +669,7 @@ announce_motd(#message{to = To} = Packet) -> announce_motd(To#jid.lserver, Packet). announce_all_hosts_motd(Packet) -> - Hosts = ?MYHOSTS, + Hosts = ejabberd_config:get_myhosts(), [announce_motd(Host, Packet) || Host <- Hosts]. announce_motd(Host, Packet) -> @@ -685,7 +684,7 @@ announce_motd_update(#message{to = To} = Packet) -> announce_motd_update(To#jid.lserver, Packet). announce_all_hosts_motd_update(Packet) -> - Hosts = ?MYHOSTS, + Hosts = ejabberd_config:get_myhosts(), [announce_motd_update(Host, Packet) || Host <- Hosts]. announce_motd_update(LServer, Packet) -> @@ -703,7 +702,7 @@ announce_all_hosts_motd_delete(_Packet) -> fun(Host) -> Mod = gen_mod:db_mod(Host, ?MODULE), delete_motd(Mod, Host) - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). -spec send_motd({presence(), ejabberd_c2s:state()}) -> {presence(), ejabberd_c2s:state()}. send_motd({_, #{pres_last := _}} = Acc) -> diff --git a/src/mod_block_strangers.erl b/src/mod_block_strangers.erl index d6d5c50cb..6f25b6417 100644 --- a/src/mod_block_strangers.erl +++ b/src/mod_block_strangers.erl @@ -35,7 +35,6 @@ -export([filter_packet/1, filter_offline_msg/1, filter_subscription/2]). -include("xmpp.hrl"). --include("ejabberd.hrl"). -include("logger.hrl"). -define(SETS, gb_sets). diff --git a/src/mod_blocking.erl b/src/mod_blocking.erl index c1646b9e3..a67e51683 100644 --- a/src/mod_blocking.erl +++ b/src/mod_blocking.erl @@ -32,7 +32,6 @@ -export([start/2, stop/1, reload/3, process_iq/1, depends/2, disco_features/5, mod_options/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_bosh.erl b/src/mod_bosh.erl index face1692c..2aca662c1 100644 --- a/src/mod_bosh.erl +++ b/src/mod_bosh.erl @@ -38,7 +38,6 @@ -export([depends/2, mod_opt_type/1, mod_options/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include_lib("stdlib/include/ms_transform.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_bosh_redis.erl b/src/mod_bosh_redis.erl index 3fcd36d07..7c7cf6578 100644 --- a/src/mod_bosh_redis.erl +++ b/src/mod_bosh_redis.erl @@ -34,7 +34,6 @@ -export([init/1, handle_cast/2, handle_call/3, handle_info/2, terminate/2, code_change/3, start_link/0]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("bosh.hrl"). diff --git a/src/mod_bosh_sql.erl b/src/mod_bosh_sql.erl index 012a61da0..c32714c87 100644 --- a/src/mod_bosh_sql.erl +++ b/src/mod_bosh_sql.erl @@ -31,7 +31,6 @@ %% API -export([init/0, open_session/2, close_session/1, find_session/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("ejabberd_sql_pt.hrl"). @@ -42,7 +41,7 @@ init() -> Node = erlang:atom_to_binary(node(), latin1), ?DEBUG("Cleaning SQL 'bosh' table...", []), case ejabberd_sql:sql_query( - ?MYNAME, ?SQL("delete from bosh where node=%(Node)s")) of + ejabberd_config:get_myname(), ?SQL("delete from bosh where node=%(Node)s")) of {updated, _} -> ok; Err -> @@ -53,7 +52,7 @@ init() -> open_session(SID, Pid) -> PidS = misc:encode_pid(Pid), Node = erlang:atom_to_binary(node(Pid), latin1), - case ?SQL_UPSERT(?MYNAME, "bosh", + case ?SQL_UPSERT(ejabberd_config:get_myname(), "bosh", ["!sid=%(SID)s", "node=%(Node)s", "pid=%(PidS)s"]) of @@ -65,7 +64,7 @@ open_session(SID, Pid) -> close_session(SID) -> case ejabberd_sql:sql_query( - ?MYNAME, ?SQL("delete from bosh where sid=%(SID)s")) of + ejabberd_config:get_myname(), ?SQL("delete from bosh where sid=%(SID)s")) of {updated, _} -> ok; _Err -> @@ -74,7 +73,7 @@ close_session(SID) -> find_session(SID) -> case ejabberd_sql:sql_query( - ?MYNAME, + ejabberd_config:get_myname(), ?SQL("select @(pid)s, @(node)s from bosh where sid=%(SID)s")) of {selected, [{Pid, Node}]} -> try {ok, misc:decode_pid(Pid, Node)} diff --git a/src/mod_caps.erl b/src/mod_caps.erl index 19838cc8a..3d2b52dac 100644 --- a/src/mod_caps.erl +++ b/src/mod_caps.erl @@ -51,7 +51,6 @@ -export([user_send_packet/1, user_receive_packet/1, c2s_presence_in/2, mod_opt_type/1, mod_options/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). @@ -162,7 +161,7 @@ caps_stream_features(Acc, MyHost) -> <<"">> -> Acc; Hash -> - [#caps{hash = <<"sha-1">>, node = ?EJABBERD_URI, + [#caps{hash = <<"sha-1">>, node = ejabberd_config:get_uri(), version = Hash} | Acc] end; false -> @@ -476,9 +475,9 @@ concat_xdata_fields(#xdata{fields = Fields} = X) -> -spec is_valid_node(binary()) -> boolean(). is_valid_node(Node) -> case str:tokens(Node, <<"#">>) of - [?EJABBERD_URI|_] -> - true; - _ -> + [H|_] -> + H == ejabberd_config:get_uri(); + [] -> false end. diff --git a/src/mod_carboncopy.erl b/src/mod_carboncopy.erl index 5b7983ddf..83bebecb7 100644 --- a/src/mod_carboncopy.erl +++ b/src/mod_carboncopy.erl @@ -39,7 +39,6 @@ is_carbon_copy/1, mod_opt_type/1, depends/2, clean_cache/1, mod_options/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("mod_carboncopy.hrl"). diff --git a/src/mod_carboncopy_redis.erl b/src/mod_carboncopy_redis.erl index 52ca06252..90b55168e 100644 --- a/src/mod_carboncopy_redis.erl +++ b/src/mod_carboncopy_redis.erl @@ -30,7 +30,6 @@ -export([init/1, handle_cast/2, handle_call/3, handle_info/2, terminate/2, code_change/3, start_link/0]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("mod_carboncopy.hrl"). diff --git a/src/mod_carboncopy_sql.erl b/src/mod_carboncopy_sql.erl index 6bc69cfd3..46b6ea806 100644 --- a/src/mod_carboncopy_sql.erl +++ b/src/mod_carboncopy_sql.erl @@ -28,7 +28,6 @@ %% API -export([init/2, enable/4, disable/3, list/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("ejabberd_sql_pt.hrl"). diff --git a/src/mod_client_state.erl b/src/mod_client_state.erl index a6c7f89c0..99a810fdb 100644 --- a/src/mod_client_state.erl +++ b/src/mod_client_state.erl @@ -40,7 +40,6 @@ c2s_authenticated_packet/2, csi_activity/2, c2s_copy_session/2, c2s_session_resumed/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_configure.erl b/src/mod_configure.erl index 74b3cc793..9cf96ce70 100644 --- a/src/mod_configure.erl +++ b/src/mod_configure.erl @@ -38,7 +38,6 @@ adhoc_sm_items/4, adhoc_sm_commands/4, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("ejabberd_sm.hrl"). @@ -753,7 +752,7 @@ get_stopped_nodes(_Lang) -> lists:map( fun (N) -> S = iolist_to_binary(atom_to_list(N)), - #disco_item{jid = jid:make(?MYNAME), + #disco_item{jid = jid:make(ejabberd_config:get_myname()), node = <<"stopped nodes/", S/binary>>, name = S} end, @@ -1525,7 +1524,7 @@ set_form(From, Host, ?NS_ADMINL(<<"add-user">>), _Lang, AccountJID = jid:decode(AccountString), User = AccountJID#jid.luser, Server = AccountJID#jid.lserver, - true = lists:member(Server, ?MYHOSTS), + true = lists:member(Server, ejabberd_config:get_myhosts()), true = Server == Host orelse get_permission_level(From) == global, case ejabberd_auth:try_register(User, Server, Password) of diff --git a/src/mod_delegation.erl b/src/mod_delegation.erl index 1dd8fb724..690d41b2f 100644 --- a/src/mod_delegation.erl +++ b/src/mod_delegation.erl @@ -40,7 +40,7 @@ disco_local_features/5, disco_sm_features/5, disco_local_identity/5, disco_sm_identity/5]). --include("ejabberd.hrl"). +-include("type_compat.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). @@ -88,7 +88,7 @@ component_connected(Host) -> fun(ServerHost) -> Proc = gen_mod:get_module_proc(ServerHost, ?MODULE), gen_server:cast(Proc, {component_connected, Host}) - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). -spec component_disconnected(binary(), binary()) -> ok. component_disconnected(Host, _Reason) -> @@ -96,7 +96,7 @@ component_disconnected(Host, _Reason) -> fun(ServerHost) -> Proc = gen_mod:get_module_proc(ServerHost, ?MODULE), gen_server:cast(Proc, {component_disconnected, Host}) - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). -spec ejabberd_local(iq()) -> iq(). ejabberd_local(IQ) -> diff --git a/src/mod_disco.erl b/src/mod_disco.erl index 1c51e40e4..170134559 100644 --- a/src/mod_disco.erl +++ b/src/mod_disco.erl @@ -40,7 +40,6 @@ get_info/5, transform_module_options/1, mod_opt_type/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("translate.hrl"). -include("xmpp.hrl"). @@ -239,7 +238,7 @@ get_vh_services(Host) -> Hosts = lists:sort(fun (H1, H2) -> byte_size(H1) >= byte_size(H2) end, - ?MYHOSTS), + ejabberd_config:get_myhosts()), lists:filter(fun (H) -> case lists:dropwhile(fun (VH) -> not diff --git a/src/mod_echo.erl b/src/mod_echo.erl index 7e8c70cb9..6be1f76dd 100644 --- a/src/mod_echo.erl +++ b/src/mod_echo.erl @@ -38,7 +38,6 @@ handle_info/2, terminate/2, code_change/3, mod_opt_type/1, depends/2, mod_options/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_fail2ban.erl b/src/mod_fail2ban.erl index 618e4b6e4..3e6fec62f 100644 --- a/src/mod_fail2ban.erl +++ b/src/mod_fail2ban.erl @@ -37,7 +37,6 @@ mod_opt_type/1, mod_options/1, depends/2]). -include_lib("stdlib/include/ms_transform.hrl"). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_http_api.erl b/src/mod_http_api.erl index e8ca866a1..e451b82c8 100644 --- a/src/mod_http_api.erl +++ b/src/mod_http_api.erl @@ -77,7 +77,6 @@ -export([start/2, stop/1, reload/3, process/2, mod_opt_type/1, depends/2, mod_options/1]). --include("ejabberd.hrl"). -include("xmpp.hrl"). -include("logger.hrl"). -include("ejabberd_http.hrl"). diff --git a/src/mod_http_fileserver.erl b/src/mod_http_fileserver.erl index 0175456d1..47cf31bce 100644 --- a/src/mod_http_fileserver.erl +++ b/src/mod_http_fileserver.erl @@ -45,7 +45,6 @@ -export([reopen_log/0, mod_opt_type/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("ejabberd_http.hrl"). -include_lib("kernel/include/file.hrl"). @@ -277,7 +276,7 @@ process(LocalPath, #request{host = Host, auth = Auth, headers = RHeaders} = Requ "but couldn't find the related " "ejabberd virtual host", [Host]), {FileSize1, Code1, Headers1, Contents1} = ?HTTP_ERR_HOST_UNKNOWN, - add_to_log(FileSize1, Code1, Request#request{host = ?MYNAME}), + add_to_log(FileSize1, Code1, Request#request{host = ejabberd_config:get_myname()}), {Code1, Headers1, Contents1} end. @@ -383,7 +382,7 @@ reopen_log() -> lists:foreach( fun(Host) -> gen_server:cast(get_proc_name(Host), reopen_log) - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). add_to_log(FileSize, Code, Request) -> gen_server:cast(get_proc_name(Request#request.host), diff --git a/src/mod_http_upload.erl b/src/mod_http_upload.erl index 1ece69f62..8cbdc126d 100644 --- a/src/mod_http_upload.erl +++ b/src/mod_http_upload.erl @@ -89,7 +89,6 @@ expand_home/1, expand_host/2]). --include("ejabberd.hrl"). -include("ejabberd_http.hrl"). -include("xmpp.hrl"). -include("logger.hrl"). diff --git a/src/mod_irc.erl b/src/mod_irc.erl index 254f05b58..42e516b82 100644 --- a/src/mod_irc.erl +++ b/src/mod_irc.erl @@ -41,7 +41,6 @@ handle_info/2, terminate/2, code_change/3, mod_opt_type/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("mod_irc.hrl"). @@ -437,10 +436,9 @@ iq_disco(ServerHost, Node, Lang) -> end. iq_get_vcard(Lang) -> - Desc = translate:translate(Lang, <<"ejabberd IRC module">>), #vcard_temp{fn = <<"ejabberd/mod_irc">>, - url = ?EJABBERD_URI, - desc = <>}. + url = ejabberd_config:get_uri(), + desc = misc:get_descr(Lang, <<"ejabberd IRC module">>)}. command_items(ServerHost, Host, Lang) -> lists:map(fun({Node, Name, _Function}) -> diff --git a/src/mod_irc_connection.erl b/src/mod_irc_connection.erl index daa329877..78b50a1b9 100644 --- a/src/mod_irc_connection.erl +++ b/src/mod_irc_connection.erl @@ -39,7 +39,7 @@ handle_sync_event/4, handle_info/3, terminate/3, code_change/4]). --include("ejabberd.hrl"). +-include("type_compat.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). @@ -645,7 +645,7 @@ terminate(_Reason, _StateName, FullStateData) -> {error, SError, SStateData} -> {SError, SStateData}; _ -> {xmpp:err_internal_server_error( - <<"Server Connect Failed">>, ?MYLANG), + <<"Server Connect Failed">>, ejabberd_config:get_mylang()), FullStateData} end, (StateData#state.mod):closed_connection(StateData#state.host, @@ -804,7 +804,7 @@ error_nick_in_use(_StateData, String) -> Msg = ejabberd_regexp:replace(String, <<".*433 +[^ ]* +">>, <<"">>), Msg1 = filter_message(Msg), - xmpp:err_conflict(Msg1, ?MYLANG). + xmpp:err_conflict(Msg1, ejabberd_config:get_mylang()). process_nick_in_use(StateData, String) -> Error = error_nick_in_use(StateData, String), @@ -950,7 +950,7 @@ process_version(StateData, _Nick, From) -> send_text(StateData, io_lib:format("NOTICE ~s :\001VERSION ejabberd IRC " "transport ~s (c) Alexey Shchepin\001\r\n", - [FromUser, ?VERSION]) + [FromUser, ejabberd_config:get_version()]) ++ io_lib:format("NOTICE ~s :\001VERSION http://ejabberd.jabber" "studio.org/\001\r\n", @@ -1128,14 +1128,14 @@ process_error(StateData, String) -> StateData#state.nick), to = StateData#state.user, type = error, - sub_els = [xmpp:err_internal_server_error(String, ?MYLANG)]}) + sub_els = [xmpp:err_internal_server_error(String, ejabberd_config:get_mylang())]}) end, dict:fetch_keys(StateData#state.channels)). error_unknown_num(_StateData, String, Type) -> Msg = ejabberd_regexp:replace(String, <<".*[45][0-9][0-9] +[^ ]* +">>, <<"">>), Msg1 = filter_message(Msg), - xmpp:err_undefined_condition(Type, Msg1, ?MYLANG). + xmpp:err_undefined_condition(Type, Msg1, ejabberd_config:get_mylang()). remove_element(E, Set) -> case (?SETS):is_element(E, Set) of diff --git a/src/mod_last.erl b/src/mod_last.erl index ae02b15ad..f0651b054 100644 --- a/src/mod_last.erl +++ b/src/mod_last.erl @@ -37,7 +37,6 @@ remove_user/2, mod_opt_type/1, mod_options/1, register_user/2, depends/2, privacy_check_packet/4]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_mam.erl b/src/mod_mam.erl index 6c2a0358d..d971983ab 100644 --- a/src/mod_mam.erl +++ b/src/mod_mam.erl @@ -520,7 +520,7 @@ delete_old_messages(TypeBin, Days) when TypeBin == <<"chat">>; sql -> {sql, Host}; Other -> {Other, global} end - end, ?MYHOSTS)), + end, ejabberd_config:get_myhosts())), Results = lists:map( fun({DBType, ServerHost}) -> Mod = gen_mod:db_mod(DBType, ?MODULE), diff --git a/src/mod_metrics.erl b/src/mod_metrics.erl index 69888eee2..282dca7ef 100644 --- a/src/mod_metrics.erl +++ b/src/mod_metrics.erl @@ -28,7 +28,6 @@ -author('christophe.romain@process-one.net'). -behaviour(gen_mod). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_muc.erl b/src/mod_muc.erl index 6cfeb55d5..d7b2fa052 100644 --- a/src/mod_muc.erl +++ b/src/mod_muc.erl @@ -71,7 +71,6 @@ handle_info/2, terminate/2, code_change/3, mod_opt_type/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("mod_muc.hrl"). @@ -463,11 +462,10 @@ do_route1(Host, ServerHost, Access, HistorySize, RoomShaper, -spec process_vcard(iq()) -> iq(). process_vcard(#iq{type = get, lang = Lang, sub_els = [#vcard_temp{}]} = IQ) -> - Desc = translate:translate(Lang, <<"ejabberd MUC module">>), xmpp:make_iq_result( IQ, #vcard_temp{fn = <<"ejabberd/mod_muc">>, - url = ?EJABBERD_URI, - desc = <>}); + url = ejabberd_config:get_uri(), + desc = misc:get_descr(Lang, <<"ejabberd MUC module">>)}); process_vcard(#iq{type = set, lang = Lang} = IQ) -> Txt = <<"Value 'set' of 'type' attribute is not allowed">>, xmpp:make_error(IQ, xmpp:err_not_allowed(Txt, Lang)); @@ -1016,7 +1014,7 @@ mod_options(Host) -> {allow_visitor_status,true}, {anonymous,true}, {captcha_protected,false}, - {lang, ?MYLANG}, + {lang, ejabberd_config:get_mylang()}, {logging,false}, {members_by_default,true}, {members_only,false}, diff --git a/src/mod_muc_admin.erl b/src/mod_muc_admin.erl index 5a89dab4e..cff855d6d 100644 --- a/src/mod_muc_admin.erl +++ b/src/mod_muc_admin.erl @@ -42,7 +42,6 @@ subscribe_room/4, unsubscribe_room/2, get_subscribers/2, web_page_host/3, mod_options/1, get_commands_spec/0]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("mod_muc.hrl"). @@ -388,7 +387,7 @@ get_user_rooms(User, Server) -> false -> [] end - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). %%---------------------------- %% Ad-hoc commands @@ -710,9 +709,9 @@ create_rooms_file(Filename) -> Rooms = read_rooms(F, RJID, []), file:close(F), %% Read the default room options defined for the first virtual host - DefRoomOpts = gen_mod:get_module_opt(?MYNAME, mod_muc, + DefRoomOpts = gen_mod:get_module_opt(ejabberd_config:get_myname(), mod_muc, default_room_options), - [muc_create_room(?MYNAME, A, DefRoomOpts) || A <- Rooms], + [muc_create_room(ejabberd_config:get_myname(), A, DefRoomOpts) || A <- Rooms], ok. @@ -814,7 +813,7 @@ seconds_to_days(S) -> %% Act act_on_rooms(Action, Rooms, ServerHost) -> - ServerHosts = [ {A, find_host(A)} || A <- ?MYHOSTS ], + ServerHosts = [ {A, find_host(A)} || A <- ejabberd_config:get_myhosts() ], Delete = fun({_N, H, _Pid} = Room) -> SH = case ServerHost of global -> find_serverhost(H, ServerHosts); @@ -1236,7 +1235,7 @@ find_hosts(Global) when Global == global; false -> [] end - end, ?MYHOSTS); + end, ejabberd_config:get_myhosts()); find_hosts(ServerHost) when is_list(ServerHost) -> find_hosts(list_to_binary(ServerHost)); find_hosts(ServerHost) -> diff --git a/src/mod_muc_log.erl b/src/mod_muc_log.erl index 4a936c66e..2e47a19da 100644 --- a/src/mod_muc_log.erl +++ b/src/mod_muc_log.erl @@ -41,7 +41,6 @@ handle_info/2, terminate/2, code_change/3, mod_opt_type/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_muc_room.erl b/src/mod_muc_room.erl index 7779cd5e3..a1cab2236 100644 --- a/src/mod_muc_room.erl +++ b/src/mod_muc_room.erl @@ -50,7 +50,6 @@ terminate/3, code_change/4]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). @@ -2155,7 +2154,7 @@ send_self_presence(JID, State) -> DiscoInfo = make_disco_info(JID, State), DiscoHash = mod_caps:compute_disco_hash(DiscoInfo, sha), Els1 = [#caps{hash = <<"sha-1">>, - node = ?EJABBERD_URI, + node = ejabberd_config:get_uri(), version = DiscoHash}], Els2 = if is_binary(AvatarHash) -> [#vcard_xupdate{hash = AvatarHash}|Els1]; @@ -3836,7 +3835,7 @@ process_iq_disco_info(From, #iq{type = get, lang = Lang, true = mod_caps:is_valid_node(Node), DiscoInfo = make_disco_info(From, StateData), Hash = mod_caps:compute_disco_hash(DiscoInfo, sha), - Node = <<(?EJABBERD_URI)/binary, $#, Hash/binary>>, + Node = <<(ejabberd_config:get_uri())/binary, $#, Hash/binary>>, Extras = iq_disco_info_extras(Lang, StateData, true), {result, DiscoInfo#disco_info{node = Node, xdata = [Extras]}} catch _:{badmatch, _} -> diff --git a/src/mod_multicast.erl b/src/mod_multicast.erl index 846049a55..b015dff45 100644 --- a/src/mod_multicast.erl +++ b/src/mod_multicast.erl @@ -42,7 +42,6 @@ -export([purge_loop/1, mod_opt_type/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("translate.hrl"). -include("xmpp.hrl"). @@ -254,10 +253,9 @@ iq_disco_info(From, Lang, State) -> xdata = iq_disco_info_extras(From, State)}. iq_vcard(Lang) -> - Desc = translate:translate(Lang, <<"ejabberd Multicast service">>), #vcard_temp{fn = <<"ejabberd/mod_multicast">>, - url = ?EJABBERD_URI, - desc = <>}. + url = ejabberd_config:get_uri(), + desc = misc:get_descr(Lang, <<"ejabberd Multicast service">>)}. %%%------------------------- %%% Route @@ -1034,7 +1032,7 @@ iq_disco_info_extras(From, State) -> end. sender_type(From) -> - Local_hosts = (?MYHOSTS), + Local_hosts = ejabberd_config:get_myhosts(), case lists:member(From#jid.lserver, Local_hosts) of true -> local; false -> remote diff --git a/src/mod_offline.erl b/src/mod_offline.erl index 83d092ba1..695cc6a94 100644 --- a/src/mod_offline.erl +++ b/src/mod_offline.erl @@ -67,7 +67,6 @@ -deprecated({get_queue_length,2}). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_ping.erl b/src/mod_ping.erl index 9939fb89c..6df9aa65a 100644 --- a/src/mod_ping.erl +++ b/src/mod_ping.erl @@ -33,7 +33,6 @@ -behaviour(gen_server). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_pres_counter.erl b/src/mod_pres_counter.erl index f2a8fac8f..6c58d2641 100644 --- a/src/mod_pres_counter.erl +++ b/src/mod_pres_counter.erl @@ -30,7 +30,6 @@ -export([start/2, stop/1, reload/3, check_packet/4, mod_opt_type/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_privacy.erl b/src/mod_privacy.erl index cae9d8f9f..8a64c6276 100644 --- a/src/mod_privacy.erl +++ b/src/mod_privacy.erl @@ -40,7 +40,6 @@ import_start/2, import_stop/2, import/5, import_info/0, mod_opt_type/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("mod_privacy.hrl"). diff --git a/src/mod_private.erl b/src/mod_private.erl index 9c3626529..f6a57c63c 100644 --- a/src/mod_private.erl +++ b/src/mod_private.erl @@ -36,7 +36,6 @@ import/5, import_start/2, mod_opt_type/1, set_data/3, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("mod_private.hrl"). diff --git a/src/mod_privilege.erl b/src/mod_privilege.erl index ceed74d31..2188169f2 100644 --- a/src/mod_privilege.erl +++ b/src/mod_privilege.erl @@ -39,7 +39,7 @@ roster_access/2, process_message/1, process_presence_out/1, process_presence_in/1]). --include("ejabberd.hrl"). +-include("type_compat.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). @@ -76,7 +76,7 @@ component_connected(Host) -> fun(ServerHost) -> Proc = gen_mod:get_module_proc(ServerHost, ?MODULE), gen_server:cast(Proc, {component_connected, Host}) - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). -spec component_disconnected(binary(), binary()) -> ok. component_disconnected(Host, _Reason) -> @@ -84,7 +84,7 @@ component_disconnected(Host, _Reason) -> fun(ServerHost) -> Proc = gen_mod:get_module_proc(ServerHost, ?MODULE), gen_server:cast(Proc, {component_disconnected, Host}) - end, ?MYHOSTS). + end, ejabberd_config:get_myhosts()). -spec process_message(stanza()) -> stop | ok. process_message(#message{from = #jid{luser = <<"">>, lresource = <<"">>} = From, diff --git a/src/mod_proxy65_redis.erl b/src/mod_proxy65_redis.erl index 7fccbfaac..99eda70bd 100644 --- a/src/mod_proxy65_redis.erl +++ b/src/mod_proxy65_redis.erl @@ -26,7 +26,6 @@ %% API -export([init/0, register_stream/2, unregister_stream/1, activate_stream/4]). --include("ejabberd.hrl"). -include("logger.hrl"). -record(proxy65, {pid_t :: pid(), diff --git a/src/mod_proxy65_service.erl b/src/mod_proxy65_service.erl index daa93eaa6..1d8d5d0e4 100644 --- a/src/mod_proxy65_service.erl +++ b/src/mod_proxy65_service.erl @@ -37,7 +37,6 @@ process_disco_items/1, process_vcard/1, process_bytestreams/1, transform_module_options/1, delete_listener/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("translate.hrl"). @@ -156,11 +155,10 @@ process_vcard(#iq{type = set, lang = Lang} = IQ) -> Txt = <<"Value 'set' of 'type' attribute is not allowed">>, xmpp:make_error(IQ, xmpp:err_not_allowed(Txt, Lang)); process_vcard(#iq{type = get, lang = Lang} = IQ) -> - Desc = translate:translate(Lang, <<"ejabberd SOCKS5 Bytestreams module">>), xmpp:make_iq_result( IQ, #vcard_temp{fn = <<"ejabberd/mod_proxy65">>, - url = ?EJABBERD_URI, - desc = <>}). + url = ejabberd_config:get_uri(), + desc = misc:get_descr(Lang, <<"ejabberd SOCKS5 Bytestreams module">>)}). -spec process_bytestreams(iq()) -> iq(). process_bytestreams(#iq{type = get, from = JID, to = To, lang = Lang} = IQ) -> diff --git a/src/mod_proxy65_sql.erl b/src/mod_proxy65_sql.erl index d943a2d29..0f51adb55 100644 --- a/src/mod_proxy65_sql.erl +++ b/src/mod_proxy65_sql.erl @@ -28,7 +28,6 @@ %% API -export([init/0, register_stream/2, unregister_stream/1, activate_stream/4]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("ejabberd_sql_pt.hrl"). @@ -39,7 +38,7 @@ init() -> NodeS = erlang:atom_to_binary(node(), latin1), ?DEBUG("Cleaning SQL 'proxy65' table...", []), case ejabberd_sql:sql_query( - ?MYNAME, + ejabberd_config:get_myname(), ?SQL("delete from proxy65 where " "node_i=%(NodeS)s or node_t=%(NodeS)s")) of {updated, _} -> @@ -65,7 +64,7 @@ register_stream(SID, Pid) -> "values (%(SID)s, %(PidS)s, %(NodeS)s, '', '', '')")) end end, - case ejabberd_sql:sql_transaction(?MYNAME, F) of + case ejabberd_sql:sql_transaction(ejabberd_config:get_myname(), F) of {atomic, _} -> ok; {aborted, Reason} -> @@ -77,7 +76,7 @@ unregister_stream(SID) -> ejabberd_sql:sql_query_t( ?SQL("delete from proxy65 where sid=%(SID)s")) end, - case ejabberd_sql:sql_transaction(?MYNAME, F) of + case ejabberd_sql:sql_transaction(ejabberd_config:get_myname(), F) of {atomic, _} -> ok; {aborted, Reason} -> @@ -125,7 +124,7 @@ activate_stream(SID, IJID, MaxConnections, _Node) -> ejabberd_sql:abort(Err) end end, - case ejabberd_sql:sql_transaction(?MYNAME, F) of + case ejabberd_sql:sql_transaction(ejabberd_config:get_myname(), F) of {atomic, Result} -> Result; {aborted, {limit, _, _} = Limit} -> diff --git a/src/mod_proxy65_stream.erl b/src/mod_proxy65_stream.erl index 66577efac..df6bc4776 100644 --- a/src/mod_proxy65_stream.erl +++ b/src/mod_proxy65_stream.erl @@ -43,7 +43,6 @@ -include("mod_proxy65.hrl"). --include("ejabberd.hrl"). -include("logger.hrl"). -define(WAIT_TIMEOUT, 60000). diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl index eac31f616..308573442 100644 --- a/src/mod_pubsub.erl +++ b/src/mod_pubsub.erl @@ -39,7 +39,6 @@ -protocol({xep, 163, '1.2'}). -protocol({xep, 248, '0.2'}). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("pubsub.hrl"). @@ -1079,10 +1078,10 @@ iq_sm(#iq{to = To, sub_els = [SubEl]} = IQ) -> -spec iq_get_vcard(binary()) -> vcard_temp(). iq_get_vcard(Lang) -> - Desc = translate:translate(Lang, <<"ejabberd Publish-Subscribe module">>), + Desc = misc:get_descr(Lang, <<"ejabberd Publish-Subscribe module">>), #vcard_temp{fn = <<"ejabberd/mod_pubsub">>, - url = ?EJABBERD_URI, - desc = <>}. + url = ejabberd_config:get_uri(), + desc = Desc}. -spec iq_pubsub(binary() | ljid(), atom(), iq()) -> {result, pubsub()} | {error, stanza_error()}. @@ -1439,7 +1438,7 @@ update_auth(Host, Node, Type, Nidx, Subscriber, Allow, Subs) -> {result, ok}; _ -> Txt = <<"No pending subscriptions found">>, - {error, xmpp:err_unexpected_request(Txt, ?MYLANG)} + {error, xmpp:err_unexpected_request(Txt, ejabberd_config:get_mylang())} end. %% @doc

Create new pubsub nodes

@@ -1519,7 +1518,7 @@ create_node(Host, ServerHost, Node, Owner, GivenType, Access, Configuration) -> end; _ -> Txt = <<"You're not allowed to create nodes">>, - {error, xmpp:err_forbidden(Txt, ?MYLANG)} + {error, xmpp:err_forbidden(Txt, ejabberd_config:get_mylang())} end end, Reply = #pubsub{create = Node}, @@ -1555,7 +1554,7 @@ create_node(Host, ServerHost, Node, Owner, GivenType, Access, Configuration) -> %% -spec delete_node(host(), binary(), jid()) -> {result, pubsub_owner()} | {error, stanza_error()}. delete_node(_Host, <<>>, _Owner) -> - {error, xmpp:err_not_allowed(<<"No node specified">>, ?MYLANG)}; + {error, xmpp:err_not_allowed(<<"No node specified">>, ejabberd_config:get_mylang())}; delete_node(Host, Node, Owner) -> Action = fun (#pubsub_node{type = Type, id = Nidx}) -> case node_call(Host, Type, get_affiliation, [Nidx, Owner]) of @@ -1567,7 +1566,7 @@ delete_node(Host, Node, Owner) -> Error -> Error end; _ -> - {error, xmpp:err_forbidden(<<"Owner privileges required">>, ?MYLANG)} + {error, xmpp:err_forbidden(<<"Owner privileges required">>, ejabberd_config:get_mylang())} end end, Reply = undefined, @@ -1860,7 +1859,7 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload, PubOpts, Access end; false -> Txt = <<"Automatic node creation is not enabled">>, - {error, xmpp:err_item_not_found(Txt, ?MYLANG)} + {error, xmpp:err_item_not_found(Txt, ejabberd_config:get_mylang())} end; Error -> Error @@ -2141,7 +2140,7 @@ get_affiliations(Host, Node, JID) -> {error, extended_error(xmpp:err_feature_not_implemented(), err_unsupported('modify-affiliations'))}; Affiliation /= owner -> - {error, xmpp:err_forbidden(<<"Owner privileges required">>, ?MYLANG)}; + {error, xmpp:err_forbidden(<<"Owner privileges required">>, ejabberd_config:get_mylang())}; true -> node_call(Host, Type, get_node_affiliations, [Nidx]) end @@ -2207,7 +2206,7 @@ set_affiliations(Host, Node, From, Affs) -> {result, undefined}; _ -> {error, xmpp:err_forbidden( - <<"Owner privileges required">>, ?MYLANG)} + <<"Owner privileges required">>, ejabberd_config:get_mylang())} end end, case transaction(Host, Node, Action, sync_dirty) of @@ -2402,7 +2401,7 @@ get_subscriptions(Host, Node, JID) -> {error, extended_error(xmpp:err_feature_not_implemented(), err_unsupported('manage-subscriptions'))}; Affiliation /= owner -> - {error, xmpp:err_forbidden(<<"Owner privileges required">>, ?MYLANG)}; + {error, xmpp:err_forbidden(<<"Owner privileges required">>, ejabberd_config:get_mylang())}; true -> node_call(Host, Type, get_node_subscriptions, [Nidx]) end @@ -2483,7 +2482,7 @@ set_subscriptions(Host, Node, From, Entities) -> end; _ -> {error, xmpp:err_forbidden( - <<"Owner privileges required">>, ?MYLANG)} + <<"Owner privileges required">>, ejabberd_config:get_mylang())} end end, @@ -3550,7 +3549,7 @@ tree_action(Host, Function, Args) -> {aborted, Reason} -> ?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]), ErrTxt = <<"Database failure">>, - {error, xmpp:err_internal_server_error(ErrTxt, ?MYLANG)} + {error, xmpp:err_internal_server_error(ErrTxt, ejabberd_config:get_mylang())} end; _ -> Fun() @@ -3628,10 +3627,10 @@ do_transaction(ServerHost, Fun, Trans, DBType) -> {error, Error}; {aborted, Reason} -> ?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]), - {error, xmpp:err_internal_server_error(<<"Database failure">>, ?MYLANG)}; + {error, xmpp:err_internal_server_error(<<"Database failure">>, ejabberd_config:get_mylang())}; Other -> ?ERROR_MSG("transaction return internal error: ~p~n", [Other]), - {error, xmpp:err_internal_server_error(<<"Database failure">>, ?MYLANG)} + {error, xmpp:err_internal_server_error(<<"Database failure">>, ejabberd_config:get_mylang())} end. %%%% helpers diff --git a/src/mod_push.erl b/src/mod_push.erl index 90e982840..82ab70cc9 100644 --- a/src/mod_push.erl +++ b/src/mod_push.erl @@ -49,7 +49,6 @@ %% For IQ callbacks -export([delete_session/3]). --include("ejabberd.hrl"). -include("ejabberd_commands.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). @@ -174,7 +173,7 @@ delete_old_sessions(Days) -> sql -> {sql, Host}; Other -> {Other, global} end - end, ?MYHOSTS)), + end, ejabberd_config:get_myhosts())), Results = lists:map( fun({DBType, Host}) -> Mod = gen_mod:db_mod(DBType, ?MODULE), diff --git a/src/mod_register.erl b/src/mod_register.erl index 5c17c5d33..3737ff96b 100644 --- a/src/mod_register.erl +++ b/src/mod_register.erl @@ -39,7 +39,6 @@ transform_options/1, transform_module_options/1, mod_opt_type/1, mod_options/1, opt_type/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_register_web.erl b/src/mod_register_web.erl index c857887ee..7bda0e67d 100644 --- a/src/mod_register_web.erl +++ b/src/mod_register_web.erl @@ -57,7 +57,6 @@ -export([start/2, stop/1, reload/3, process/2, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_roster.erl b/src/mod_roster.erl index d35b7dc97..3375220d1 100644 --- a/src/mod_roster.erl +++ b/src/mod_roster.erl @@ -52,7 +52,6 @@ mod_opt_type/1, mod_options/1, set_roster/1, del_roster/3, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). @@ -980,7 +979,7 @@ build_contact_jid_td(RosterJID) -> of {<<"">>, _} -> <<"">>; {CUser, CServer} -> - case lists:member(CServer, ?MYHOSTS) of + case lists:member(CServer, ejabberd_config:get_myhosts()) of false -> <<"">>; true -> <<"/admin/server/", CServer/binary, "/user/", diff --git a/src/mod_s2s_dialback.erl b/src/mod_s2s_dialback.erl index d5ba83b0c..fa77e7d36 100644 --- a/src/mod_s2s_dialback.erl +++ b/src/mod_s2s_dialback.erl @@ -32,7 +32,6 @@ s2s_in_packet/2, s2s_out_packet/2, s2s_in_recv/3, s2s_in_features/2, s2s_out_init/2, s2s_out_closed/2]). --include("ejabberd.hrl"). -include("xmpp.hrl"). -include("logger.hrl"). diff --git a/src/mod_service_log.erl b/src/mod_service_log.erl index 2f4aa7395..27ec8af44 100644 --- a/src/mod_service_log.erl +++ b/src/mod_service_log.erl @@ -32,7 +32,6 @@ -export([start/2, stop/1, log_user_send/1, mod_options/1, log_user_receive/1, mod_opt_type/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_shared_roster.erl b/src/mod_shared_roster.erl index 84ab34286..34f5502eb 100644 --- a/src/mod_shared_roster.erl +++ b/src/mod_shared_roster.erl @@ -41,7 +41,6 @@ is_user_in_group/3, add_user_to_group/3, opts_to_binary/1, remove_user_from_group/3, mod_opt_type/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_shared_roster_ldap.erl b/src/mod_shared_roster_ldap.erl index 04db34efe..b50ad93d0 100644 --- a/src/mod_shared_roster_ldap.erl +++ b/src/mod_shared_roster_ldap.erl @@ -44,7 +44,6 @@ out_subscription/1, mod_opt_type/1, mod_options/1, opt_type/1, depends/2, transform_module_options/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("mod_roster.hrl"). diff --git a/src/mod_sic.erl b/src/mod_sic.erl index ef043c642..765b9adcd 100644 --- a/src/mod_sic.erl +++ b/src/mod_sic.erl @@ -34,7 +34,6 @@ -export([start/2, stop/1, reload/3, process_local_iq/1, process_sm_iq/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_sip.erl b/src/mod_sip.erl index c40e4eb7c..daed4fa19 100644 --- a/src/mod_sip.erl +++ b/src/mod_sip.erl @@ -51,7 +51,6 @@ mod_options(_) -> message_out/2, request/2, request/3, response/2, locate/1, mod_opt_type/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include_lib("esip/include/esip.hrl"). %%%=================================================================== @@ -61,7 +60,8 @@ start(_Host, _Opts) -> ejabberd:start_app(esip), esip:set_config_value(max_server_transactions, 10000), esip:set_config_value(max_client_transactions, 10000), - esip:set_config_value(software, <<"ejabberd ", (?VERSION)/binary>>), + esip:set_config_value( + software, <<"ejabberd ", (ejabberd_config:get_version())/binary>>), esip:set_config_value(module, ?MODULE), Spec = {mod_sip_registrar, {mod_sip_registrar, start_link, []}, transient, 2000, worker, [mod_sip_registrar]}, diff --git a/src/mod_sip_proxy.erl b/src/mod_sip_proxy.erl index 0e7f367df..3ee0a6fee 100644 --- a/src/mod_sip_proxy.erl +++ b/src/mod_sip_proxy.erl @@ -38,7 +38,6 @@ handle_sync_event/4, handle_info/3, terminate/3, code_change/4]). --include("ejabberd.hrl"). -include("logger.hrl"). -include_lib("esip/include/esip.hrl"). diff --git a/src/mod_sip_registrar.erl b/src/mod_sip_registrar.erl index 346b3be19..d7b959435 100644 --- a/src/mod_sip_registrar.erl +++ b/src/mod_sip_registrar.erl @@ -40,7 +40,6 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --include("ejabberd.hrl"). -include("logger.hrl"). -include_lib("esip/include/esip.hrl"). diff --git a/src/mod_stats.erl b/src/mod_stats.erl index 197335259..706c22a70 100644 --- a/src/mod_stats.erl +++ b/src/mod_stats.erl @@ -34,7 +34,6 @@ -export([start/2, stop/1, reload/3, process_iq/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). @@ -137,7 +136,7 @@ get_local_stat(_Server, [], Name) ejabberd_auth:count_users(Host) + Total end, - 0, ?MYHOSTS), + 0, ejabberd_config:get_myhosts()), ?STATVAL((integer_to_binary(NumUsers)), <<"users">>); get_local_stat(_Server, _, Name) -> diff --git a/src/mod_stream_mgmt.erl b/src/mod_stream_mgmt.erl index 5ebd16cb0..c0ab394ad 100644 --- a/src/mod_stream_mgmt.erl +++ b/src/mod_stream_mgmt.erl @@ -36,7 +36,6 @@ %% adjust pending session timeout / access queue -export([get_resume_timeout/1, set_resume_timeout/2, queue_find/2]). --include("ejabberd.hrl"). -include("xmpp.hrl"). -include("logger.hrl"). -include("p1_queue.hrl"). diff --git a/src/mod_time.erl b/src/mod_time.erl index 3ecd0ae47..78c75f8af 100644 --- a/src/mod_time.erl +++ b/src/mod_time.erl @@ -35,7 +35,6 @@ -export([start/2, stop/1, reload/3, process_local_iq/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_vcard.erl b/src/mod_vcard.erl index b23e87c84..e1cc902a4 100644 --- a/src/mod_vcard.erl +++ b/src/mod_vcard.erl @@ -42,7 +42,6 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). -include("mod_vcard.hrl"). @@ -197,17 +196,16 @@ process_local_iq(#iq{type = set, lang = Lang} = IQ) -> Txt = <<"Value 'set' of 'type' attribute is not allowed">>, xmpp:make_error(IQ, xmpp:err_not_allowed(Txt, Lang)); process_local_iq(#iq{type = get, lang = Lang} = IQ) -> - Desc = translate:translate(Lang, <<"Erlang Jabber Server">>), xmpp:make_iq_result( IQ, #vcard_temp{fn = <<"ejabberd">>, - url = ?EJABBERD_URI, - desc = <>, + url = ejabberd_config:get_uri(), + desc = misc:get_descr(Lang, <<"Erlang Jabber Server">>), bday = <<"2002-11-16">>}). -spec process_sm_iq(iq()) -> iq(). process_sm_iq(#iq{type = set, lang = Lang, from = From} = IQ) -> #jid{lserver = LServer} = From, - case lists:member(LServer, ?MYHOSTS) of + case lists:member(LServer, ejabberd_config:get_myhosts()) of true -> case ejabberd_hooks:run_fold(vcard_iq_set, LServer, IQ, []) of drop -> ignore; @@ -235,11 +233,10 @@ process_vcard(#iq{type = set, lang = Lang} = IQ) -> Txt = <<"Value 'set' of 'type' attribute is not allowed">>, xmpp:make_error(IQ, xmpp:err_not_allowed(Txt, Lang)); process_vcard(#iq{type = get, lang = Lang} = IQ) -> - Desc = translate:translate(Lang, <<"ejabberd vCard module">>), xmpp:make_iq_result( IQ, #vcard_temp{fn = <<"ejabberd/mod_vcard">>, - url = ?EJABBERD_URI, - desc = <>}). + url = ejabberd_config:get_uri(), + desc = misc:get_descr(Lang, <<"ejabberd vCard module">>)}). -spec process_search(iq()) -> iq(). process_search(#iq{type = get, to = To, lang = Lang} = IQ) -> diff --git a/src/mod_vcard_ldap.erl b/src/mod_vcard_ldap.erl index 51de22e4c..acfd0a052 100644 --- a/src/mod_vcard_ldap.erl +++ b/src/mod_vcard_ldap.erl @@ -38,7 +38,6 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("eldap.hrl"). -include("xmpp.hrl"). @@ -159,7 +158,7 @@ search_items(Entries, State) -> Attrs, VCardMap, {Username, - ?MYNAME})} + ejabberd_config:get_myname()})} end, SearchReported), J = <>, diff --git a/src/mod_vcard_mnesia.erl b/src/mod_vcard_mnesia.erl index e759627ec..f7e2872aa 100644 --- a/src/mod_vcard_mnesia.erl +++ b/src/mod_vcard_mnesia.erl @@ -33,7 +33,6 @@ -export([need_transform/1, transform/1]). -export([mod_opt_type/1, mod_options/1]). --include("ejabberd.hrl"). -include("xmpp.hrl"). -include("mod_vcard.hrl"). -include("logger.hrl"). @@ -235,9 +234,9 @@ make_val(Val) -> find_my_host(LServer) -> Parts = str:tokens(LServer, <<".">>), - find_my_host(Parts, ?MYHOSTS). + find_my_host(Parts, ejabberd_config:get_myhosts()). -find_my_host([], _Hosts) -> ?MYNAME; +find_my_host([], _Hosts) -> ejabberd_config:get_myname(); find_my_host([_ | Tail] = Parts, Hosts) -> Domain = parts_to_string(Parts), case lists:member(Domain, Hosts) of diff --git a/src/mod_vcard_xupdate.erl b/src/mod_vcard_xupdate.erl index 5c10a5a7e..2f3853357 100644 --- a/src/mod_vcard_xupdate.erl +++ b/src/mod_vcard_xupdate.erl @@ -36,7 +36,6 @@ %% API -export([compute_hash/1]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). diff --git a/src/mod_version.erl b/src/mod_version.erl index 5d261dff7..da0f736eb 100644 --- a/src/mod_version.erl +++ b/src/mod_version.erl @@ -34,7 +34,6 @@ -export([start/2, stop/1, reload/3, process_local_iq/1, mod_opt_type/1, mod_options/1, depends/2]). --include("ejabberd.hrl"). -include("logger.hrl"). -include("xmpp.hrl"). @@ -60,7 +59,7 @@ process_local_iq(#iq{type = get, to = To} = IQ) -> false -> undefined end, xmpp:make_iq_result(IQ, #version{name = <<"ejabberd">>, - ver = ?VERSION, + ver = ejabberd_config:get_version(), os = OS}). get_os() -> diff --git a/src/node_dag.erl b/src/node_dag.erl index 888b60d6b..9d84c484e 100644 --- a/src/node_dag.erl +++ b/src/node_dag.erl @@ -80,7 +80,7 @@ publish_item(Nidx, Publisher, Model, MaxItems, ItemId, Payload, PubOpts) -> collection -> Txt = <<"Publishing items to collection node is not allowed">>, {error, mod_pubsub:extended_error( - xmpp:err_not_allowed(Txt, ?MYLANG), + xmpp:err_not_allowed(Txt, ejabberd_config:get_mylang()), mod_pubsub:err_unsupported('publish'))}; _ -> node_hometree:publish_item(Nidx, Publisher, Model, diff --git a/src/node_flat_sql.erl b/src/node_flat_sql.erl index 28b855bc8..ebe164a15 100644 --- a/src/node_flat_sql.erl +++ b/src/node_flat_sql.erl @@ -767,7 +767,7 @@ get_item(Nidx, ItemId) -> {selected, []} -> {error, xmpp:err_item_not_found()}; {'EXIT', _} -> - {error, xmpp:err_internal_server_error(<<"Database failure">>, ?MYLANG)} + {error, xmpp:err_internal_server_error(<<"Database failure">>, ejabberd_config:get_mylang())} end. get_item(Nidx, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId) -> diff --git a/src/nodetree_dag.erl b/src/nodetree_dag.erl index bb51aa6d2..93f414f31 100644 --- a/src/nodetree_dag.erl +++ b/src/nodetree_dag.erl @@ -69,13 +69,13 @@ create_node(Key, Node, Type, Owner, Options, Parents) -> Other -> Other end; _ -> - {error, xmpp:err_conflict(<<"Node already exists">>, ?MYLANG)} + {error, xmpp:err_conflict(<<"Node already exists">>, ejabberd_config:get_mylang())} end. delete_node(Key, Node) -> case find_node(Key, Node) of false -> - {error, xmpp:err_item_not_found(<<"Node not found">>, ?MYLANG)}; + {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_config:get_mylang())}; Record -> lists:foreach(fun (#pubsub_node{options = Opts} = Child) -> NewOpts = remove_config_parent(Node, Opts), @@ -99,7 +99,7 @@ get_node(Host, Node, _From) -> get_node(Host, Node) -> case find_node(Host, Node) of - false -> {error, xmpp:err_item_not_found(<<"Node not found">>, ?MYLANG)}; + false -> {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_config:get_mylang())}; Record -> Record end. @@ -115,7 +115,7 @@ get_nodes(Key) -> get_parentnodes(Host, Node, _From) -> case find_node(Host, Node) of false -> - {error, xmpp:err_item_not_found(<<"Node not found">>, ?MYLANG)}; + {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_config:get_mylang())}; #pubsub_node{parents = Parents} -> Q = qlc:q([N || #pubsub_node{nodeid = {NHost, NNode}} = N @@ -139,7 +139,7 @@ get_subnodes(Host, <<>>) -> get_subnodes_helper(Host, <<>>); get_subnodes(Host, Node) -> case find_node(Host, Node) of - false -> {error, xmpp:err_item_not_found(<<"Node not found">>, ?MYLANG)}; + false -> {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_config:get_mylang())}; _ -> get_subnodes_helper(Host, Node) end. @@ -226,7 +226,7 @@ validate_parentage(Key, Owners, [<<>> | T]) -> validate_parentage(Key, Owners, [ParentID | T]) -> case find_node(Key, ParentID) of false -> - {error, xmpp:err_item_not_found(<<"Node not found">>, ?MYLANG)}; + {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_config:get_mylang())}; #pubsub_node{owners = POwners, options = POptions} -> NodeType = find_opt(node_type, ?DEFAULT_NODETYPE, POptions), MutualOwners = [O || O <- Owners, PO <- POwners, O == PO], diff --git a/src/nodetree_tree.erl b/src/nodetree_tree.erl index 0136a0c60..c0da117b0 100644 --- a/src/nodetree_tree.erl +++ b/src/nodetree_tree.erl @@ -71,13 +71,13 @@ get_node(Host, Node, _From) -> get_node(Host, Node) -> case mnesia:read({pubsub_node, {Host, Node}}) of [Record] when is_record(Record, pubsub_node) -> Record; - _ -> {error, xmpp:err_item_not_found(<<"Node not found">>, ?MYLANG)} + _ -> {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_config:get_mylang())} end. get_node(Nidx) -> case mnesia:index_read(pubsub_node, Nidx, #pubsub_node.id) of [Record] when is_record(Record, pubsub_node) -> Record; - _ -> {error, xmpp:err_item_not_found(<<"Node not found">>, ?MYLANG)} + _ -> {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_config:get_mylang())} end. get_nodes(Host, _From) -> @@ -189,7 +189,7 @@ create_node(Host, Node, Type, Owner, Options, Parents) -> {error, xmpp:err_forbidden()} end; _ -> - {error, xmpp:err_conflict(<<"Node already exists">>, ?MYLANG)} + {error, xmpp:err_conflict(<<"Node already exists">>, ejabberd_config:get_mylang())} end. delete_node(Host, Node) -> diff --git a/src/nodetree_tree_sql.erl b/src/nodetree_tree_sql.erl index 2987dbdc3..c311ea3ab 100644 --- a/src/nodetree_tree_sql.erl +++ b/src/nodetree_tree_sql.erl @@ -94,7 +94,7 @@ set_node(Record) when is_record(Record, pubsub_node) -> case Nidx of none -> Txt = <<"Node index not found">>, - {error, xmpp:err_internal_server_error(Txt, ?MYLANG)}; + {error, xmpp:err_internal_server_error(Txt, ejabberd_config:get_mylang())}; _ -> lists:foreach(fun ({Key, Value}) -> SKey = iolist_to_binary(atom_to_list(Key)), @@ -121,9 +121,9 @@ get_node(Host, Node) -> {selected, [RItem]} -> raw_to_node(Host, RItem); {'EXIT', _Reason} -> - {error, xmpp:err_internal_server_error(<<"Database failure">>, ?MYLANG)}; + {error, xmpp:err_internal_server_error(<<"Database failure">>, ejabberd_config:get_mylang())}; _ -> - {error, xmpp:err_item_not_found(<<"Node not found">>, ?MYLANG)} + {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_config:get_mylang())} end. get_node(Nidx) -> @@ -135,9 +135,9 @@ get_node(Nidx) -> {selected, [{Host, Node, Parent, Type}]} -> raw_to_node(Host, {Node, Parent, Type, Nidx}); {'EXIT', _Reason} -> - {error, xmpp:err_internal_server_error(<<"Database failure">>, ?MYLANG)}; + {error, xmpp:err_internal_server_error(<<"Database failure">>, ejabberd_config:get_mylang())}; _ -> - {error, xmpp:err_item_not_found(<<"Node not found">>, ?MYLANG)} + {error, xmpp:err_item_not_found(<<"Node not found">>, ejabberd_config:get_mylang())} end. get_nodes(Host, _From) -> @@ -259,9 +259,9 @@ create_node(Host, Node, Type, Owner, Options, Parents) -> {error, xmpp:err_forbidden()} end; {result, _} -> - {error, xmpp:err_conflict(<<"Node already exists">>, ?MYLANG)}; + {error, xmpp:err_conflict(<<"Node already exists">>, ejabberd_config:get_mylang())}; {error, db_fail} -> - {error, xmpp:err_internal_server_error(<<"Database failure">>, ?MYLANG)} + {error, xmpp:err_internal_server_error(<<"Database failure">>, ejabberd_config:get_mylang())} end. delete_node(Host, Node) -> diff --git a/src/prosody2ejabberd.erl b/src/prosody2ejabberd.erl index cfee9ae01..7da288c32 100644 --- a/src/prosody2ejabberd.erl +++ b/src/prosody2ejabberd.erl @@ -27,7 +27,7 @@ %% API -export([from_dir/1]). --include("ejabberd.hrl"). +-include("scram.hrl"). -include("xmpp.hrl"). -include("logger.hrl"). -include("mod_roster.hrl"). @@ -196,7 +196,7 @@ convert_data(_Host, "config", _User, [Data]) -> RoomCfg = convert_room_config(Data), case proplists:get_bool(<<"persistent">>, Config) of true when RoomJID /= error -> - mod_muc:store_room(?MYNAME, RoomJID#jid.lserver, + mod_muc:store_room(ejabberd_config:get_myname(), RoomJID#jid.lserver, RoomJID#jid.luser, RoomCfg); _ -> ok diff --git a/src/pubsub_subscription.erl b/src/pubsub_subscription.erl index 30cd4f090..615ab322f 100644 --- a/src/pubsub_subscription.erl +++ b/src/pubsub_subscription.erl @@ -207,13 +207,13 @@ val_xfield(digest_frequency = Opt, [Val]) -> N when is_integer(N) -> N; _ -> Txt = {<<"Value of '~s' should be integer">>, [Opt]}, - {error, xmpp:err_not_acceptable(Txt, ?MYLANG)} + {error, xmpp:err_not_acceptable(Txt, ejabberd_config:get_mylang())} end; val_xfield(expire = Opt, [Val]) -> try xmpp_util:decode_timestamp(Val) catch _:{bad_timestamp, _} -> Txt = {<<"Value of '~s' should be datetime string">>, [Opt]}, - {error, xmpp:err_not_acceptable(Txt, ?MYLANG)} + {error, xmpp:err_not_acceptable(Txt, ejabberd_config:get_mylang())} end; val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val); val_xfield(show_values, Vals) -> Vals; @@ -225,7 +225,7 @@ val_xfield(subscription_depth = Opt, [Depth]) -> N when is_integer(N) -> N; _ -> Txt = {<<"Value of '~s' should be integer">>, [Opt]}, - {error, xmpp:err_not_acceptable(Txt, ?MYLANG)} + {error, xmpp:err_not_acceptable(Txt, ejabberd_config:get_mylang())} end. %% Convert XForm booleans to Erlang booleans. @@ -235,7 +235,7 @@ xopt_to_bool(_, <<"false">>) -> false; xopt_to_bool(_, <<"true">>) -> true; xopt_to_bool(Option, _) -> Txt = {<<"Value of '~s' should be boolean">>, [Option]}, - {error, xmpp:err_not_acceptable(Txt, ?MYLANG)}. + {error, xmpp:err_not_acceptable(Txt, ejabberd_config:get_mylang())}. %% Return a field for an XForm for Key, with data filled in, if %% applicable, from Options. diff --git a/src/pubsub_subscription_sql.erl b/src/pubsub_subscription_sql.erl index 06ad73b20..2fcfb0f19 100644 --- a/src/pubsub_subscription_sql.erl +++ b/src/pubsub_subscription_sql.erl @@ -172,13 +172,13 @@ val_xfield(digest_frequency = Opt, [Val]) -> N when is_integer(N) -> N; _ -> Txt = {<<"Value of '~s' should be integer">>, [Opt]}, - {error, xmpp:err_not_acceptable(Txt, ?MYLANG)} + {error, xmpp:err_not_acceptable(Txt, ejabberd_config:get_mylang())} end; val_xfield(expire = Opt, [Val]) -> try xmpp_util:decode_timestamp(Val) catch _:{bad_timestamp, _} -> Txt = {<<"Value of '~s' should be datetime string">>, [Opt]}, - {error, xmpp:err_not_acceptable(Txt, ?MYLANG)} + {error, xmpp:err_not_acceptable(Txt, ejabberd_config:get_mylang())} end; val_xfield(include_body = Opt, [Val]) -> xopt_to_bool(Opt, Val); val_xfield(show_values, Vals) -> Vals; @@ -190,7 +190,7 @@ val_xfield(subscription_depth = Opt, [Depth]) -> N when is_integer(N) -> N; _ -> Txt = {<<"Value of '~s' should be integer">>, [Opt]}, - {error, xmpp:err_not_acceptable(Txt, ?MYLANG)} + {error, xmpp:err_not_acceptable(Txt, ejabberd_config:get_mylang())} end. %% Convert XForm booleans to Erlang booleans. @@ -200,7 +200,7 @@ xopt_to_bool(_, <<"false">>) -> false; xopt_to_bool(_, <<"true">>) -> true; xopt_to_bool(Option, _) -> Txt = {<<"Value of '~s' should be boolean">>, [Option]}, - {error, xmpp:err_not_acceptable(Txt, ?MYLANG)}. + {error, xmpp:err_not_acceptable(Txt, ejabberd_config:get_mylang())}. %% Return a field for an XForm for Key, with data filled in, if %% applicable, from Options. diff --git a/src/shaper.erl b/src/shaper.erl index 2fb0fee81..028331659 100644 --- a/src/shaper.erl +++ b/src/shaper.erl @@ -37,7 +37,6 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --include("ejabberd.hrl"). -include("logger.hrl"). -record(maxrate, {maxrate = 0 :: integer(), diff --git a/src/translate.erl b/src/translate.erl index 89059ec48..5a1e13e82 100644 --- a/src/translate.erl +++ b/src/translate.erl @@ -34,7 +34,6 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --include("ejabberd.hrl"). -include("logger.hrl"). -include_lib("kernel/include/file.hrl"). @@ -196,7 +195,7 @@ translate(Lang, Msg) -> end. translate(Msg) -> - case ?MYLANG of + case ejabberd_config:get_mylang() of <<"en">> -> Msg; Lang -> LLang = ascii_tolower(Lang), @@ -229,14 +228,7 @@ ascii_tolower_s([]) -> []. -spec get_msg_dir() -> {calendar:datetime(), file:filename()}. get_msg_dir() -> - Dir = case os:getenv("EJABBERD_MSGS_PATH") of - false -> - case code:priv_dir(ejabberd) of - {error, _} -> ?MSGS_DIR; - Path -> filename:join([Path, "msgs"]) - end; - Path -> Path - end, + Dir = misc:msgs_dir(), case file:read_file_info(Dir) of {ok, #file_info{mtime = MTime}} -> {MTime, Dir}; diff --git a/src/win32_dns.erl b/src/win32_dns.erl index 921f1731e..fe1ba5395 100644 --- a/src/win32_dns.erl +++ b/src/win32_dns.erl @@ -26,7 +26,6 @@ -module(win32_dns). -export([get_nameservers/0]). --include("ejabberd.hrl"). -include("logger.hrl"). -define(IF_KEY, "\\hklm\\system\\CurrentControlSet\\Services\\TcpIp\\Parameters\\Interfaces"). diff --git a/src/xmpp_socket.erl b/src/xmpp_socket.erl index cbff0b035..e8a520caf 100644 --- a/src/xmpp_socket.erl +++ b/src/xmpp_socket.erl @@ -53,7 +53,6 @@ pp/1, sockname/1, peername/1]). --include("ejabberd.hrl"). -include("xmpp.hrl"). -include("logger.hrl").