mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Fixed type specifications for 'rebar doc'
- Fixed type @specs and -specs to remove 'rebar doc' errors - Removed a lot of wrong and deprecated documentation in ejabberd_piefxis.erl
This commit is contained in:
parent
6e14a47316
commit
8e6a301026
@ -222,7 +222,7 @@ check_password_cache(User, Server, Password,
|
|||||||
get_password_internal(User, Server) ->
|
get_password_internal(User, Server) ->
|
||||||
ejabberd_auth_internal:get_password(User, Server).
|
ejabberd_auth_internal:get_password(User, Server).
|
||||||
|
|
||||||
%% @spec (User, Server, CacheTime) -> false | Password::string()
|
-spec get_password_cache(User::binary(), Server::binary(), CacheTime::integer()) -> Password::string() | false.
|
||||||
get_password_cache(User, Server, CacheTime) ->
|
get_password_cache(User, Server, CacheTime) ->
|
||||||
case get_last_access(User, Server) of
|
case get_last_access(User, Server) of
|
||||||
online -> get_password_internal(User, Server);
|
online -> get_password_internal(User, Server);
|
||||||
@ -273,10 +273,10 @@ is_fresh_enough(TimeStampLast, CacheTime) ->
|
|||||||
Now = p1_time_compat:system_time(seconds),
|
Now = p1_time_compat:system_time(seconds),
|
||||||
TimeStampLast + CacheTime > Now.
|
TimeStampLast + CacheTime > Now.
|
||||||
|
|
||||||
%% @spec (User, Server) -> online | never | mod_last_required | TimeStamp::integer()
|
|
||||||
%% Code copied from mod_configure.erl
|
%% Code copied from mod_configure.erl
|
||||||
%% Code copied from web/ejabberd_web_admin.erl
|
%% Code copied from web/ejabberd_web_admin.erl
|
||||||
%% TODO: Update time format to XEP-0202: Entity Time
|
%% TODO: Update time format to XEP-0202: Entity Time
|
||||||
|
-spec(get_last_access(User::binary(), Server::binary()) -> (online | never | mod_last_required | integer())).
|
||||||
get_last_access(User, Server) ->
|
get_last_access(User, Server) ->
|
||||||
case ejabberd_sm:get_user_resources(User, Server) of
|
case ejabberd_sm:get_user_resources(User, Server) of
|
||||||
[] ->
|
[] ->
|
||||||
|
@ -112,7 +112,7 @@ get_env_config() ->
|
|||||||
%% @doc Read the ejabberd configuration file.
|
%% @doc Read the ejabberd configuration file.
|
||||||
%% It also includes additional configuration files and replaces macros.
|
%% It also includes additional configuration files and replaces macros.
|
||||||
%% This function will crash if finds some error in the configuration file.
|
%% This function will crash if finds some error in the configuration file.
|
||||||
%% @spec (File::string()) -> #state{}.
|
%% @spec (File::string()) -> #state{}
|
||||||
read_file(File) ->
|
read_file(File) ->
|
||||||
read_file(File, [{replace_macros, true},
|
read_file(File, [{replace_macros, true},
|
||||||
{include_files, true},
|
{include_files, true},
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
%% "ejabberd.log" in current directory.
|
%% "ejabberd.log" in current directory.
|
||||||
%% Note: If the directory where to place the ejabberd log file to not exist,
|
%% Note: If the directory where to place the ejabberd log file to not exist,
|
||||||
%% it is not created and no log file will be generated.
|
%% it is not created and no log file will be generated.
|
||||||
|
%% @spec () -> string()
|
||||||
get_log_path() ->
|
get_log_path() ->
|
||||||
case ejabberd_config:env_binary_to_list(ejabberd, log_path) of
|
case ejabberd_config:env_binary_to_list(ejabberd, log_path) of
|
||||||
{ok, Path} ->
|
{ok, Path} ->
|
||||||
@ -99,6 +100,7 @@ get_string_env(Name, Default) ->
|
|||||||
Default
|
Default
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
%% @spec () -> ok
|
||||||
start() ->
|
start() ->
|
||||||
application:load(sasl),
|
application:load(sasl),
|
||||||
application:set_env(sasl, sasl_error_logger, false),
|
application:set_env(sasl, sasl_error_logger, false),
|
||||||
@ -126,10 +128,12 @@ start() ->
|
|||||||
ejabberd:start_app(lager),
|
ejabberd:start_app(lager),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
%% @spec () -> ok
|
||||||
reopen_log() ->
|
reopen_log() ->
|
||||||
%% Lager detects external log rotation automatically.
|
%% Lager detects external log rotation automatically.
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
%% @spec () -> ok
|
||||||
rotate_log() ->
|
rotate_log() ->
|
||||||
lager_crash_log ! rotate,
|
lager_crash_log ! rotate,
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
@ -139,6 +143,7 @@ rotate_log() ->
|
|||||||
ok
|
ok
|
||||||
end, gen_event:which_handlers(lager_event)).
|
end, gen_event:which_handlers(lager_event)).
|
||||||
|
|
||||||
|
%% @spec () -> {loglevel(), atom(), string()}
|
||||||
get() ->
|
get() ->
|
||||||
case lager:get_loglevel(lager_console_backend) of
|
case lager:get_loglevel(lager_console_backend) of
|
||||||
none -> {0, no_log, "No log"};
|
none -> {0, no_log, "No log"};
|
||||||
@ -152,6 +157,7 @@ get() ->
|
|||||||
debug -> {5, debug, "Debug"}
|
debug -> {5, debug, "Debug"}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
%% @spec (loglevel() | {loglevel(), list()}) -> {module, module()}
|
||||||
set(LogLevel) when is_integer(LogLevel) ->
|
set(LogLevel) when is_integer(LogLevel) ->
|
||||||
LagerLogLevel = case LogLevel of
|
LagerLogLevel = case LogLevel of
|
||||||
0 -> none;
|
0 -> none;
|
||||||
|
@ -80,7 +80,6 @@ import_file(FileName) ->
|
|||||||
import_file(FileName, #state{}).
|
import_file(FileName, #state{}).
|
||||||
|
|
||||||
-spec import_file(binary(), state()) -> ok | {error, atom()}.
|
-spec import_file(binary(), state()) -> ok | {error, atom()}.
|
||||||
|
|
||||||
import_file(FileName, State) ->
|
import_file(FileName, State) ->
|
||||||
case file:open(FileName, [read, binary]) of
|
case file:open(FileName, [read, binary]) of
|
||||||
{ok, Fd} ->
|
{ok, Fd} ->
|
||||||
@ -97,72 +96,14 @@ import_file(FileName, State) ->
|
|||||||
{error, Reason}
|
{error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%%==================================
|
|
||||||
%%%% Process Elements
|
|
||||||
%%%==================================
|
|
||||||
%%%% Process Element
|
|
||||||
%%%==================================
|
|
||||||
%%%% Add user
|
|
||||||
%% @spec (El::xmlel(), Domain::string(), User::binary(), Password::binary() | none)
|
|
||||||
%% -> ok | {error, ErrorText::string()}
|
|
||||||
%% @doc Add a new user to the database.
|
|
||||||
%% If user already exists, it will be only updated.
|
|
||||||
-spec export_server(binary()) -> any().
|
-spec export_server(binary()) -> any().
|
||||||
|
|
||||||
%% @spec (User::string(), Password::string(), Domain::string())
|
|
||||||
%% -> ok | {atomic, exists} | {error, not_allowed}
|
|
||||||
%% @doc Create a new user
|
|
||||||
export_server(Dir) ->
|
export_server(Dir) ->
|
||||||
export_hosts(?MYHOSTS, Dir).
|
export_hosts(?MYHOSTS, Dir).
|
||||||
|
|
||||||
%%%==================================
|
|
||||||
%%%% Populate user
|
|
||||||
%% @spec (User::string(), Domain::string(), El::xml())
|
|
||||||
%% -> ok | {error, not_found}
|
|
||||||
%%
|
|
||||||
%% @doc Add a new user from a XML file with a roster list.
|
|
||||||
%%
|
|
||||||
%% Example of a file:
|
|
||||||
%% ```
|
|
||||||
%% <?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
%% <server-data xmlns='http://www.xmpp.org/extensions/xep-0227.html#ns'>
|
|
||||||
%% <host jid='localhost'>
|
|
||||||
%% <user name='juliet' password='s3crEt'>
|
|
||||||
%% <query xmlns='jabber:iq:roster'>
|
|
||||||
%% <item jid='romeo@montague.net'
|
|
||||||
%% name='Romeo'
|
|
||||||
%% subscription='both'>
|
|
||||||
%% <group>Friends</group>
|
|
||||||
%% </item>
|
|
||||||
%% </query>
|
|
||||||
%% </user>
|
|
||||||
%% </host>
|
|
||||||
%% </server-data>
|
|
||||||
%% '''
|
|
||||||
-spec export_host(binary(), binary()) -> any().
|
-spec export_host(binary(), binary()) -> any().
|
||||||
|
|
||||||
export_host(Dir, Host) ->
|
export_host(Dir, Host) ->
|
||||||
export_hosts([Host], Dir).
|
export_hosts([Host], Dir).
|
||||||
|
|
||||||
%% @spec User = String with the user name
|
|
||||||
%% Domain = String with a domain name
|
|
||||||
%% El = Sub XML element with vCard tags values
|
|
||||||
%% @ret ok | {error, not_found}
|
|
||||||
%% @doc Read vcards from the XML and send it to the server
|
|
||||||
%%
|
|
||||||
%% Example:
|
|
||||||
%% ```
|
|
||||||
%% <?xml version='1.0' encoding='UTF-8'?>
|
|
||||||
%% <server-data xmlns='http://www.xmpp.org/extensions/xep-0227.html#ns'>
|
|
||||||
%% <host jid='localhost'>
|
|
||||||
%% <user name='admin' password='s3crEt'>
|
|
||||||
%% <vCard xmlns='vcard-temp'>
|
|
||||||
%% <FN>Admin</FN>
|
|
||||||
%% </vCard>
|
|
||||||
%% </user>
|
|
||||||
%% </host>
|
|
||||||
%% </server-data>
|
|
||||||
%% '''
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Internal functions
|
%%% Internal functions
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
@ -194,11 +135,6 @@ export_hosts(Hosts, Dir) ->
|
|||||||
{error, Reason}
|
{error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @spec User = String with the user name
|
|
||||||
%% Domain = String with a domain name
|
|
||||||
%% El = Sub XML element with offline messages values
|
|
||||||
%% @ret ok | {error, not_found}
|
|
||||||
%% @doc Read off-line message from the XML and send it to the server
|
|
||||||
export_host(Dir, FnH, Host) ->
|
export_host(Dir, FnH, Host) ->
|
||||||
DFn = make_host_basefilename(Dir, FnH),
|
DFn = make_host_basefilename(Dir, FnH),
|
||||||
case file:open(DFn, [raw, write]) of
|
case file:open(DFn, [raw, write]) of
|
||||||
@ -223,11 +159,6 @@ export_host(Dir, FnH, Host) ->
|
|||||||
{error, Reason}
|
{error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @spec User = String with the user name
|
|
||||||
%% Domain = String with a domain name
|
|
||||||
%% El = Sub XML element with private storage values
|
|
||||||
%% @ret ok | {error, not_found}
|
|
||||||
%% @doc Private storage parsing
|
|
||||||
export_users([{User, _S}|Users], Server, Fd) ->
|
export_users([{User, _S}|Users], Server, Fd) ->
|
||||||
case export_user(User, Server, Fd) of
|
case export_user(User, Server, Fd) of
|
||||||
ok ->
|
ok ->
|
||||||
@ -238,8 +169,6 @@ export_users([{User, _S}|Users], Server, Fd) ->
|
|||||||
export_users([], _Server, _Fd) ->
|
export_users([], _Server, _Fd) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
%%%==================================
|
|
||||||
%%%% Utilities
|
|
||||||
export_user(User, Server, Fd) ->
|
export_user(User, Server, Fd) ->
|
||||||
Password = ejabberd_auth:get_password_s(User, Server),
|
Password = ejabberd_auth:get_password_s(User, Server),
|
||||||
LServer = jid:nameprep(Server),
|
LServer = jid:nameprep(Server),
|
||||||
@ -289,7 +218,6 @@ get_vcard(User, Server) ->
|
|||||||
[]
|
[]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%%==================================
|
|
||||||
get_offline(User, Server) ->
|
get_offline(User, Server) ->
|
||||||
case mod_offline:get_offline_els(User, Server) of
|
case mod_offline:get_offline_els(User, Server) of
|
||||||
[] ->
|
[] ->
|
||||||
@ -306,7 +234,6 @@ get_offline(User, Server) ->
|
|||||||
[#xmlel{name = <<"offline-messages">>, children = NewEls}]
|
[#xmlel{name = <<"offline-messages">>, children = NewEls}]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%%% Export hosts
|
|
||||||
get_privacy(User, Server) ->
|
get_privacy(User, Server) ->
|
||||||
case mod_privacy:get_user_lists(User, Server) of
|
case mod_privacy:get_user_lists(User, Server) of
|
||||||
{ok, #privacy{default = Default,
|
{ok, #privacy{default = Default,
|
||||||
@ -333,7 +260,6 @@ get_privacy(User, Server) ->
|
|||||||
[]
|
[]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @spec (Dir::string(), Hosts::[string()]) -> ok
|
|
||||||
get_roster(User, Server) ->
|
get_roster(User, Server) ->
|
||||||
JID = jid:make(User, Server, <<>>),
|
JID = jid:make(User, Server, <<>>),
|
||||||
case mod_roster:get_roster(User, Server) of
|
case mod_roster:get_roster(User, Server) of
|
||||||
@ -576,8 +502,6 @@ process_roster(El, State = #state{user = U, server = S}) ->
|
|||||||
stop("Failed to write roster: ~p", [Err])
|
stop("Failed to write roster: ~p", [Err])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%%==================================
|
|
||||||
%%%% Export server
|
|
||||||
process_privacy(El, State = #state{user = U, server = S}) ->
|
process_privacy(El, State = #state{user = U, server = S}) ->
|
||||||
JID = jid:make(U, S, <<"">>),
|
JID = jid:make(U, S, <<"">>),
|
||||||
case mod_privacy:process_iq_set(
|
case mod_privacy:process_iq_set(
|
||||||
@ -603,7 +527,6 @@ process_privacy(El, State = #state{user = U, server = S}) ->
|
|||||||
{ok, State}
|
{ok, State}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @spec (Dir::string()) -> ok
|
|
||||||
process_private(El, State = #state{user = U, server = S}) ->
|
process_private(El, State = #state{user = U, server = S}) ->
|
||||||
JID = jid:make(U, S, <<"">>),
|
JID = jid:make(U, S, <<"">>),
|
||||||
case mod_private:process_sm_iq(
|
case mod_private:process_sm_iq(
|
||||||
@ -614,8 +537,6 @@ process_private(El, State = #state{user = U, server = S}) ->
|
|||||||
stop("Failed to write private: ~p", [Err])
|
stop("Failed to write private: ~p", [Err])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%%%==================================
|
|
||||||
%%%% Export host
|
|
||||||
process_vcard(El, State = #state{user = U, server = S}) ->
|
process_vcard(El, State = #state{user = U, server = S}) ->
|
||||||
JID = jid:make(U, S, <<"">>),
|
JID = jid:make(U, S, <<"">>),
|
||||||
case mod_vcard:process_sm_iq(
|
case mod_vcard:process_sm_iq(
|
||||||
@ -626,7 +547,6 @@ process_vcard(El, State = #state{user = U, server = S}) ->
|
|||||||
stop("Failed to write vcard: ~p", [Err])
|
stop("Failed to write vcard: ~p", [Err])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @spec (Dir::string(), Host::string()) -> ok
|
|
||||||
process_offline_msg(El, State = #state{user = U, server = S}) ->
|
process_offline_msg(El, State = #state{user = U, server = S}) ->
|
||||||
FromS = fxml:get_attr_s(<<"from">>, El#xmlel.attrs),
|
FromS = fxml:get_attr_s(<<"from">>, El#xmlel.attrs),
|
||||||
case jid:from_string(FromS) of
|
case jid:from_string(FromS) of
|
||||||
@ -643,7 +563,6 @@ process_offline_msg(El, State = #state{user = U, server = S}) ->
|
|||||||
stop("Invalid 'from' = ~s", [FromS])
|
stop("Invalid 'from' = ~s", [FromS])
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @spec (Dir::string(), Fn::string(), Host::string()) -> ok
|
|
||||||
process_presence(El, #state{user = U, server = S} = State) ->
|
process_presence(El, #state{user = U, server = S} = State) ->
|
||||||
FromS = fxml:get_attr_s(<<"from">>, El#xmlel.attrs),
|
FromS = fxml:get_attr_s(<<"from">>, El#xmlel.attrs),
|
||||||
case jid:from_string(FromS) of
|
case jid:from_string(FromS) of
|
||||||
|
@ -1775,6 +1775,20 @@ update_auth(Host, Node, Type, Nidx, Subscriber, Allow, Subs) ->
|
|||||||
%%<li>nodetree create_node checks if nodeid already exists</li>
|
%%<li>nodetree create_node checks if nodeid already exists</li>
|
||||||
%%<li>node plugin create_node just sets default affiliation/subscription</li>
|
%%<li>node plugin create_node just sets default affiliation/subscription</li>
|
||||||
%%</ul>
|
%%</ul>
|
||||||
|
-spec(create_node/5 ::
|
||||||
|
(
|
||||||
|
Host :: mod_pubsub:host(),
|
||||||
|
ServerHost :: binary(),
|
||||||
|
Node :: <<>> | mod_pubsub:nodeId(),
|
||||||
|
Owner :: jid(),
|
||||||
|
Type :: binary())
|
||||||
|
-> {result, [xmlel(),...]}
|
||||||
|
%%%
|
||||||
|
| {error, xmlel()}
|
||||||
|
).
|
||||||
|
create_node(Host, ServerHost, Node, Owner, Type) ->
|
||||||
|
create_node(Host, ServerHost, Node, Owner, Type, all, []).
|
||||||
|
|
||||||
-spec(create_node/7 ::
|
-spec(create_node/7 ::
|
||||||
(
|
(
|
||||||
Host :: mod_pubsub:host(),
|
Host :: mod_pubsub:host(),
|
||||||
@ -1788,8 +1802,6 @@ update_auth(Host, Node, Type, Nidx, Subscriber, Allow, Subs) ->
|
|||||||
%%%
|
%%%
|
||||||
| {error, xmlel()}
|
| {error, xmlel()}
|
||||||
).
|
).
|
||||||
create_node(Host, ServerHost, Node, Owner, Type) ->
|
|
||||||
create_node(Host, ServerHost, Node, Owner, Type, all, []).
|
|
||||||
create_node(Host, ServerHost, <<>>, Owner, Type, Access, Configuration) ->
|
create_node(Host, ServerHost, <<>>, Owner, Type, Access, Configuration) ->
|
||||||
case lists:member(<<"instant-nodes">>, plugin_features(Host, Type)) of
|
case lists:member(<<"instant-nodes">>, plugin_features(Host, Type)) of
|
||||||
true ->
|
true ->
|
||||||
|
Loading…
Reference in New Issue
Block a user