The option allows to set arbitrary text for disco#info identity name.
Previously, option 'name' was supported by mod_proxy65 and mod_http_upload
only. Now, all the following modules support this option as well:
- mod_disco
- mod_irc
- mod_muc
- mod_multicast
- mod_pubsub
- mod_vcard
Example:
```
modules:
...
mod_disco:
name: "Cool XMPP Server"
...
```
-include("ejabberd.hrl").
-include("logger.hrl").
-
+-include("translate.hrl").
-include("xmpp.hrl").
-include_lib("stdlib/include/ms_transform.hrl").
-include("mod_roster.hrl").
-spec get_local_identity([identity()], jid(), jid(),
binary(), binary()) -> [identity()].
-get_local_identity(Acc, _From, _To, <<"">>, _Lang) ->
+get_local_identity(Acc, _From, To, <<"">>, _Lang) ->
+ Host = To#jid.lserver,
+ Name = gen_mod:get_module_opt(Host, ?MODULE, name, ?T("ejabberd")),
Acc ++ [#identity{category = <<"server">>,
type = <<"im">>,
- name = <<"ejabberd">>}];
+ name = Name}];
get_local_identity(Acc, _From, _To, _Node, _Lang) ->
Acc.
mod_opt_type(extra_domains) ->
fun (Hs) -> [iolist_to_binary(H) || H <- Hs] end;
mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1;
+mod_opt_type(name) -> fun iolist_to_binary/1;
mod_opt_type(server_info) ->
fun (L) ->
lists:map(fun (Opts) ->
end,
L)
end;
-mod_opt_type(_) -> [extra_domains, iqdisc, server_info].
+mod_opt_type(_) -> [extra_domains, iqdisc, server_info, name].
-include("ejabberd_http.hrl").
-include("xmpp.hrl").
-include("logger.hrl").
+-include("translate.hrl").
-record(state,
{server_host :: binary(),
init([ServerHost, Opts]) ->
process_flag(trap_exit, true),
Hosts = gen_mod:get_opt_hosts(ServerHost, Opts, <<"upload.@HOST@">>),
- Name = gen_mod:get_opt(name, Opts, <<"HTTP File Upload">>),
+ Name = gen_mod:get_opt(name, Opts, ?T("HTTP File Upload")),
Access = gen_mod:get_opt(access, Opts, local),
MaxSize = gen_mod:get_opt(max_size, Opts, 104857600),
SecretLength = gen_mod:get_opt(secret_length, Opts, 40),
-include("logger.hrl").
-include("xmpp.hrl").
-include("mod_irc.hrl").
+-include("translate.hrl").
-define(DEFAULT_IRC_ENCODING, <<"iso8859-15">>).
closed_connection(Host, From, Server) ->
ets:delete(irc_connection, {From, Server, Host}).
-iq_disco(_ServerHost, <<"">>, Lang) ->
+iq_disco(ServerHost, <<"">>, Lang) ->
+ Name = gen_mod:get_module_opt(ServerHost, ?MODULE, name, ?T("IRC Transport")),
#disco_info{
identities = [#identity{category = <<"conference">>,
type = <<"irc">>,
- name = translate:translate(Lang, <<"IRC Transport">>)}],
+ name = translate:translate(Lang, Name)}],
features = [?NS_DISCO_INFO, ?NS_DISCO_ITEMS, ?NS_MUC,
?NS_REGISTER, ?NS_VCARD, ?NS_COMMANDS]};
iq_disco(ServerHost, Node, Lang) ->
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
mod_opt_type(default_encoding) ->
fun iolist_to_binary/1;
+mod_opt_type(name) ->
+ fun iolist_to_binary/1;
mod_opt_type(host) -> fun iolist_to_binary/1;
mod_opt_type(hosts) ->
fun (L) -> lists:map(fun iolist_to_binary/1, L) end;
mod_opt_type(_) ->
- [access, db_type, default_encoding, host, hosts].
+ [access, db_type, default_encoding, host, hosts, name].
-spec extract_ident(stanza()) -> binary().
extract_ident(Packet) ->
-include("logger.hrl").
-include("xmpp.hrl").
-include("mod_muc.hrl").
+-include("translate.hrl").
-record(state,
{hosts = [] :: [binary()],
Features = [?NS_DISCO_INFO, ?NS_DISCO_ITEMS,
?NS_REGISTER, ?NS_MUC, ?NS_VCARD, ?NS_MUCSUB, ?NS_MUC_UNIQUE
| RSMFeatures ++ MAMFeatures],
+ Name = gen_mod:get_module_opt(ServerHost, ?MODULE, name, ?T("Chatrooms")),
Identity = #identity{category = <<"conference">>,
type = <<"text">>,
- name = translate:translate(Lang, <<"Chatrooms">>)},
+ name = translate:translate(Lang, Name)},
xmpp:make_iq_result(
IQ, #disco_info{features = Features,
identities = [Identity],
mod_opt_type(history_size) ->
fun (I) when is_integer(I), I >= 0 -> I end;
mod_opt_type(host) -> fun iolist_to_binary/1;
+mod_opt_type(name) -> fun iolist_to_binary/1;
mod_opt_type(hosts) ->
fun (L) -> lists:map(fun iolist_to_binary/1, L) end;
mod_opt_type(max_room_desc) ->
end;
mod_opt_type(_) ->
[access, access_admin, access_create, access_persistent,
- db_type, ram_db_type, history_size, host, hosts,
+ db_type, ram_db_type, history_size, host, hosts, name,
max_room_desc, max_room_id, max_room_name,
max_rooms_discoitems, max_user_conferences, max_users,
max_users_admin_threshold, max_users_presence,
-include("ejabberd.hrl").
-include("logger.hrl").
-
+-include("translate.hrl").
-include("xmpp.hrl").
-record(state,
-define(FEATURE(Feat), Feat).
iq_disco_info(From, Lang, State) ->
+ Name = gen_mod:get_module_opt(State#state.lserver, ?MODULE,
+ name, ?T("Multicast")),
#disco_info{
identities = [#identity{category = <<"service">>,
type = <<"multicast">>,
- name = translate:translate(Lang, <<"Multicast">>)}],
+ name = translate:translate(Lang, Name)}],
features = [?NS_DISCO_INFO, ?NS_DISCO_ITEMS, ?NS_VCARD, ?NS_ADDRESS],
xdata = iq_disco_info_extras(From, State)}.
mod_opt_type(access) ->
fun acl:access_rules_validator/1;
mod_opt_type(host) -> fun iolist_to_binary/1;
+mod_opt_type(name) -> fun iolist_to_binary/1;
mod_opt_type({limits, Type}) when (Type == local) or (Type == remote) ->
fun(L) ->
lists:map(
({presence, I} = O) when is_integer(I) -> O
end, L)
end;
-mod_opt_type(_) -> [access, host, {limits, local}, {limits, remote}].
+mod_opt_type(_) -> [access, host, {limits, local}, {limits, remote}, name].
-include("ejabberd.hrl").
-include("logger.hrl").
-include("xmpp.hrl").
+-include("translate.hrl").
-define(PROCNAME, ejabberd_mod_proxy65_service).
process_disco_info(#iq{type = get, to = To, lang = Lang} = IQ) ->
Host = ejabberd_router:host_of_route(To#jid.lserver),
Name = gen_mod:get_module_opt(Host, mod_proxy65, name,
- <<"SOCKS5 Bytestreams">>),
+ ?T("SOCKS5 Bytestreams")),
Info = ejabberd_hooks:run_fold(disco_info, Host,
[], [Host, ?MODULE, <<"">>, <<"">>]),
xmpp:make_iq_result(
-include("xmpp.hrl").
-include("pubsub.hrl").
-include("mod_roster.hrl").
+-include("translate.hrl").
-define(STDTREE, <<"tree">>).
-define(STDNODE, <<"flat">>).
Info = ejabberd_hooks:run_fold(disco_info, ServerHost,
[],
[ServerHost, ?MODULE, <<>>, <<>>]),
- case iq_disco_info(Host, Node, From, Lang) of
+ case iq_disco_info(ServerHost, Host, Node, From, Lang) of
{result, IQRes} ->
XData = IQRes#disco_info.xdata ++ Info,
xmpp:make_iq_result(IQ, IQRes#disco_info{node = Node, xdata = XData});
Other -> Other
end.
--spec iq_disco_info(binary(), binary(), jid(), binary())
+-spec iq_disco_info(binary(), binary(), binary(), jid(), binary())
-> {result, disco_info()} | {error, stanza_error()}.
-iq_disco_info(Host, SNode, From, Lang) ->
+iq_disco_info(ServerHost, Host, SNode, From, Lang) ->
[Node | _] = case SNode of
<<>> -> [<<>>];
_ -> str:tokens(SNode, <<"!">>)
end,
case Node of
<<>> ->
+ Name = gen_mod:get_module_opt(ServerHost, ?MODULE, name,
+ ?T("Publish-Subscribe")),
{result,
#disco_info{
identities = [#identity{
category = <<"pubsub">>,
type = <<"service">>,
- name = translate:translate(
- Lang, <<"Publish-Subscribe">>)}],
+ name = translate:translate(Lang, Name)}],
features = [?NS_DISCO_INFO,
?NS_DISCO_ITEMS,
?NS_PUBSUB,
mod_opt_type(access_createnode) -> fun acl:access_rules_validator/1;
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
+mod_opt_type(name) -> fun iolist_to_binary/1;
mod_opt_type(host) -> fun iolist_to_binary/1;
mod_opt_type(hosts) ->
fun (L) -> lists:map(fun iolist_to_binary/1, L) end;
mod_opt_type(plugins) ->
fun (A) when is_list(A) -> A end;
mod_opt_type(_) ->
- [access_createnode, db_type, host, hosts,
+ [access_createnode, db_type, host, hosts, name,
ignore_pep_from_offline, iqdisc, last_item_cache,
max_items_node, nodetree, pep_mapping, plugins,
max_subscriptions_node, default_node_config].
-include("logger.hrl").
-include("xmpp.hrl").
-include("mod_vcard.hrl").
+-include("translate.hrl").
-define(JUD_MATCHES, 30).
-define(VCARD_CACHE, vcard_cache).
-spec disco_identity([identity()], jid(), jid(),
binary(), binary()) -> [identity()].
-disco_identity(Acc, _From, _To, <<"">>, Lang) ->
+disco_identity(Acc, _From, To, <<"">>, Lang) ->
+ Host = ejabberd_router:host_of_route(To#jid.lserver),
+ Name = gen_mod:get_module_opt(Host, ?MODULE, name, ?T("vCard User Search")),
[#identity{category = <<"directory">>,
type = <<"user">>,
- name = translate:translate(Lang, <<"vCard User Search">>)}|Acc];
+ name = translate:translate(Lang, Name)}|Acc];
disco_identity(Acc, _From, _To, _Node, _Lang) ->
Acc.
mod_opt_type(allow_return_all) ->
fun (B) when is_boolean(B) -> B end;
mod_opt_type(db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;
+mod_opt_type(name) -> fun iolist_to_binary/1;
mod_opt_type(host) -> fun iolist_to_binary/1;
mod_opt_type(hosts) ->
fun (L) -> lists:map(fun iolist_to_binary/1, L) end;
mod_opt_type(_) ->
[allow_return_all, db_type, host, hosts, iqdisc, matches,
search, search_all_hosts, cache_life_time, cache_size,
- use_cache, cache_missed].
+ use_cache, cache_missed, name].