25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +01:00

Don't call modules that were obsoleted by GS

This commit is contained in:
Badlop 2010-07-30 13:21:25 +02:00
parent 8a5b08e3f0
commit 92dc45ad76
8 changed files with 67 additions and 139 deletions

View File

@ -15,10 +15,9 @@
ejabberd_auth_anonymous,
ejabberd_auth,
ejabberd_auth_external,
ejabberd_auth_internal,
ejabberd_auth_ldap,
ejabberd_auth_odbc,
ejabberd_auth_pam,
ejabberd_auth_storage,
ejabberd,
ejabberd_c2s,
ejabberd_c2s_config,
@ -75,16 +74,12 @@
mod_http_bind,
mod_http_fileserver,
mod_last,
mod_last_odbc,
mod_muc,
mod_muc_log,
mod_muc_room,
mod_offline,
mod_offline_odbc,
mod_privacy,
mod_privacy_odbc,
mod_private,
mod_private_odbc,
mod_proxy65,
mod_proxy65_lib,
mod_proxy65_service,
@ -93,14 +88,12 @@
mod_pubsub,
mod_register,
mod_roster,
mod_roster_odbc,
mod_service_log,
mod_shared_roster,
mod_stats,
mod_time,
mod_vcard,
mod_vcard_ldap,
mod_vcard_odbc,
mod_version,
node_buddy,
node_club,

View File

@ -66,8 +66,8 @@
-include("ejabberd.hrl").
%% @type authmodule() = ejabberd_auth_anonymous | ejabberd_auth_external |
%% ejabberd_auth_internal | ejabberd_auth_ldap |
%% ejabberd_auth_odbc | ejabberd_auth_pam | atom().
%% ejabberd_auth_ldap | ejabberd_auth_pam |
%% ejabberd_auth_storage | atom().
%%%----------------------------------------------------------------------
%%% API

View File

@ -60,7 +60,7 @@ start(Host) ->
Host, ejabberd_config:get_local_option({extauth_program, Host})),
case check_cache_last_options(Host) of
cache ->
ok = ejabberd_auth_internal:start(Host);
ok = ejabberd_auth_storage:start(Host);
no_cache ->
ok
end.
@ -112,7 +112,7 @@ check_password(User, Server, Password, _Digest, _DigestGen) ->
set_password(User, Server, Password) ->
case extauth:set_password(User, Server, Password) of
true -> set_password_internal(User, Server, Password),
true -> set_password_storage(User, Server, Password),
ok;
_ -> {error, unknown_problem}
end.
@ -133,22 +133,22 @@ try_register(User, Server, Password) ->
%% @doc Return the list of all users handled by external.
dirty_get_registered_users() ->
ejabberd_auth_internal:dirty_get_registered_users().
ejabberd_auth_storage:dirty_get_registered_users().
get_vh_registered_users(Server) ->
ejabberd_auth_internal:get_vh_registered_users(Server).
ejabberd_auth_storage:get_vh_registered_users(Server).
get_vh_registered_users(Server, Data) ->
ejabberd_auth_internal:get_vh_registered_users(Server, Data).
ejabberd_auth_storage:get_vh_registered_users(Server, Data).
%% @spec (Server) -> nil()
%% Server = string()
get_vh_registered_users_number(Server) ->
ejabberd_auth_internal:get_vh_registered_users_number(Server).
ejabberd_auth_storage:get_vh_registered_users_number(Server).
get_vh_registered_users_number(Server, Data) ->
ejabberd_auth_internal:get_vh_registered_users_number(Server, Data).
ejabberd_auth_storage:get_vh_registered_users_number(Server, Data).
%% @spec (User, Server) -> bool()
%% User = string()
@ -194,7 +194,7 @@ remove_user(User, Server) ->
case get_cache_option(Server) of
false -> false;
{true, _CacheTime} ->
ejabberd_auth_internal:remove_user(User, Server)
ejabberd_auth_storage:remove_user(User, Server)
end
end.
@ -210,7 +210,7 @@ remove_user(User, Server, Password) ->
case get_cache_option(Server) of
false -> false;
{true, _CacheTime} ->
ejabberd_auth_internal:remove_user(User, Server, Password)
ejabberd_auth_storage:remove_user(User, Server, Password)
end
end.
@ -236,7 +236,7 @@ try_register_extauth(User, Server, Password) ->
check_password_cache(User, Server, Password, CacheTime) ->
case get_last_access(User, Server) of
online ->
check_password_internal(User, Server, Password);
check_password_storage(User, Server, Password);
never ->
check_password_external_cache(User, Server, Password);
mod_last_required ->
@ -247,7 +247,7 @@ check_password_cache(User, Server, Password, CacheTime) ->
case is_fresh_enough(TimeStamp, CacheTime) of
%% If no need to refresh, check password against Mnesia
true ->
case check_password_internal(User, Server, Password) of
case check_password_storage(User, Server, Password) of
%% If password valid in Mnesia, accept it
true ->
true;
@ -261,14 +261,14 @@ check_password_cache(User, Server, Password, CacheTime) ->
end
end.
get_password_internal(User, Server) ->
ejabberd_auth_internal:get_password(User, Server).
get_password_storage(User, Server) ->
ejabberd_auth_storage:get_password(User, Server).
%% @spec (User, Server, CacheTime) -> Password::string() | false
get_password_cache(User, Server, CacheTime) ->
case get_last_access(User, Server) of
online ->
get_password_internal(User, Server);
get_password_storage(User, Server);
never ->
false;
mod_last_required ->
@ -277,7 +277,7 @@ get_password_cache(User, Server, CacheTime) ->
TimeStamp ->
case is_fresh_enough(TimeStamp, CacheTime) of
true ->
get_password_internal(User, Server);
get_password_storage(User, Server);
false ->
false
end
@ -288,7 +288,7 @@ get_password_cache(User, Server, CacheTime) ->
check_password_external_cache(User, Server, Password) ->
case check_password_extauth(User, Server, Password) of
true ->
set_password_internal(User, Server, Password), true;
set_password_storage(User, Server, Password), true;
false ->
false
end.
@ -297,18 +297,18 @@ check_password_external_cache(User, Server, Password) ->
try_register_external_cache(User, Server, Password) ->
case try_register_extauth(User, Server, Password) of
{atomic, ok} = R ->
set_password_internal(User, Server, Password),
set_password_storage(User, Server, Password),
R;
_ -> {error, not_allowed}
end.
%% @spec (User, Server, Password) -> true | false
check_password_internal(User, Server, Password) ->
ejabberd_auth_internal:check_password(User, Server, Password).
check_password_storage(User, Server, Password) ->
ejabberd_auth_storage:check_password(User, Server, Password).
%% @spec (User, Server, Password) -> ok | {error, invalid_jid}
set_password_internal(User, Server, Password) ->
ejabberd_auth_internal:set_password(User, Server, Password).
set_password_storage(User, Server, Password) ->
ejabberd_auth_storage:set_password(User, Server, Password).
%% @spec (TimeLast, CacheTime) -> true | false
%% TimeLast = online | never | integer()
@ -347,19 +347,15 @@ get_last_access(UserS, ServerS) ->
get_last_info(User, Server) ->
case get_mod_last_enabled(Server) of
mod_last -> mod_last:get_last_info(User, Server);
mod_last_odbc -> mod_last_odbc:get_last_info(User, Server);
no_mod_last -> mod_last_required
end.
%% @spec (Server) -> mod_last | mod_last_odbc | no_mod_last
%% @spec (Server) -> mod_last | no_mod_last
get_mod_last_enabled(ServerB) when is_binary(ServerB)->
Server = binary_to_list(ServerB),
get_mod_last_enabled(Server);
get_mod_last_enabled(Server) ->
ML = lists:member(mod_last, gen_mod:loaded_modules(Server)),
MLO = lists:member(mod_last_odbc, gen_mod:loaded_modules(Server)),
case {ML, MLO} of
{true, _} -> mod_last;
{false, true} -> mod_last_odbc;
{false, false} -> no_mod_last
case lists:member(mod_last, gen_mod:loaded_modules(Server)) of
true -> mod_last;
false -> no_mod_last
end.

View File

@ -227,7 +227,7 @@ create_user(User,Password,Domain) ->
populate_user(User,Domain,El=#xmlel{name='query', ns='jabber:iq:roster'}) ->
io:format("Trying to add/update roster list...",[]),
case loaded_module(Domain,[mod_roster_odbc,mod_roster]) of
case loaded_module(Domain,[mod_roster]) of
{ok, M} ->
case M:set_items(User, Domain, El) of
{atomic, ok} ->
@ -240,7 +240,7 @@ populate_user(User,Domain,El=#xmlel{name='query', ns='jabber:iq:roster'}) ->
{error, not_found}
end;
E -> io:format(" ERROR: ~p~n",[E]),
?ERROR_MSG("No modules loaded [mod_roster, mod_roster_odbc] ~s ~n",
?ERROR_MSG("Module not loaded: mod_roster ~s ~n",
[exmpp_xml:document_to_list(El)]),
{error, not_found}
end;
@ -268,7 +268,7 @@ populate_user(User,Domain,El=#xmlel{name='query', ns='jabber:iq:roster'}) ->
populate_user(User,Domain,El=#xmlel{name='vCard', ns='vcard-temp'}) ->
io:format("Trying to add/update vCards...",[]),
case loaded_module(Domain,[mod_vcard,mod_vcard_odbc]) of
case loaded_module(Domain,[mod_vcard]) of
{ok, M} -> FullUser = exmpp_jid:make(User, Domain),
IQ = #iq{kind=request, type = set, payload = El},
case M:process_sm_iq(FullUser, FullUser , IQ) of
@ -281,7 +281,7 @@ populate_user(User,Domain,El=#xmlel{name='vCard', ns='vcard-temp'}) ->
end;
_ ->
io:format(" ERROR.~n",[]),
?ERROR_MSG("No modules loaded [mod_vcard, mod_vcard_odbc] ~s ~n",
?ERROR_MSG("Module not loaded: mod_vcard ~s ~n",
[exmpp_xml:document_to_list(El)]),
{error, not_found}
end;
@ -294,7 +294,7 @@ populate_user(User,Domain,El=#xmlel{name='vCard', ns='vcard-temp'}) ->
populate_user(User,Domain,El=#xmlel{name='offline-messages'}) ->
io:format("Trying to add/update offline-messages...",[]),
case loaded_module(Domain, [mod_offline, mod_offline_odbc]) of
case loaded_module(Domain, [mod_offline]) of
{ok, M} ->
ok = exmpp_xml:foreach(
fun (_Element, {xmlcdata, _}) ->
@ -307,7 +307,7 @@ populate_user(User,Domain,El=#xmlel{name='offline-messages'}) ->
end, El), io:format(" DONE.~n",[]);
_ ->
io:format(" ERROR.~n",[]),
?ERROR_MSG("No modules loaded [mod_offline, mod_offline_odbc] ~s ~n",
?ERROR_MSG("Module not loaded: mod_offline ~s ~n",
[exmpp_xml:document_to_list(El)]),
{error, not_found}
end;
@ -320,7 +320,7 @@ populate_user(User,Domain,El=#xmlel{name='offline-messages'}) ->
populate_user(User,Domain,El=#xmlel{name='query', ns='jabber:iq:private'}) ->
io:format("Trying to add/update private storage...",[]),
case loaded_module(Domain,[mod_private_odbc,mod_private]) of
case loaded_module(Domain,[mod_private]) of
{ok, M} ->
FullUser = exmpp_jid:make(User, Domain),
IQ = #iq{type = set,
@ -337,7 +337,7 @@ populate_user(User,Domain,El=#xmlel{name='query', ns='jabber:iq:private'}) ->
end;
_ ->
io:format(" ERROR.~n",[]),
?ERROR_MSG("No modules loaded [mod_private, mod_private_odbc] ~s~n",
?ERROR_MSG("Module not loaded: mod_private ~s~n",
[exmpp_xml:document_to_list(El)]),
{error, not_found}
end;
@ -482,7 +482,7 @@ extract_user(Username, Host) ->
%% @spec (InfoName::atom(), Username::string(), Host::string()) -> string()
extract_user_info(roster, Username, Host) ->
case loaded_module(Host,[mod_roster_odbc,mod_roster]) of
case loaded_module(Host,[mod_roster]) of
{ok, M} ->
From = To = exmpp_jid:make(Username, Host, ""),
SubelGet = exmpp_xml:element(?NS_ROSTER, 'query', [], []),
@ -497,7 +497,7 @@ extract_user_info(roster, Username, Host) ->
end;
extract_user_info(offline, Username, Host) ->
case loaded_module(Host,[mod_offline,mod_offline_odbc]) of
case loaded_module(Host,[mod_offline]) of
{ok, mod_offline} ->
Els = mnesia_pop_offline_messages([], Username, Host),
case Els of
@ -508,24 +508,20 @@ extract_user_info(offline, Username, Host) ->
%OfEl = {xmlelement, "offline-messages", [], Els},
exmpp_xml:document_to_list(OfEl)
end;
{ok, mod_offline_odbc} ->
"";
_E ->
""
end;
extract_user_info(private, Username, Host) ->
case loaded_module(Host,[mod_private,mod_private_odbc]) of
case loaded_module(Host,[mod_private]) of
{ok, mod_private} ->
get_user_private_mnesia(Username, Host);
{ok, mod_private_odbc} ->
"";
_E ->
""
end;
extract_user_info(vcard, Username, Host) ->
case loaded_module(Host,[mod_vcard, mod_vcard_odbc, mod_vcard_odbc]) of
case loaded_module(Host,[mod_vcard]) of
{ok, M} ->
From = To = exmpp_jid:make(Username, Host, ""),
SubelGet = exmpp_xml:element(?NS_VCARD, 'vCard', [], []),

View File

@ -116,7 +116,6 @@ xdb_data(_User, _Server, #xmlcdata{}) ->
ok;
xdb_data(User, Server, #xmlel{ns = NS} = El) ->
From = exmpp_jid:make(User, Server),
LServer = exmpp_stringprep:nameprep(Server),
UserB = list_to_binary(User),
ServerB = list_to_binary(Server),
case NS of
@ -125,47 +124,22 @@ xdb_data(User, Server, #xmlel{ns = NS} = El) ->
ejabberd_auth:set_password(UserB, ServerB, Password),
ok;
?NS_ROSTER ->
case lists:member(mod_roster_odbc,
gen_mod:loaded_modules(LServer)) of
true ->
catch mod_roster_odbc:set_items(UserB, ServerB, El);
false ->
catch mod_roster:set_items(UserB, ServerB, El)
end,
catch mod_roster:set_items(UserB, ServerB, El),
ok;
?NS_LAST_ACTIVITY ->
TimeStamp = exmpp_xml:get_attribute_as_list(El, 'last', ""),
Status = exmpp_xml:get_cdata(El),
case lists:member(mod_last_odbc,
gen_mod:loaded_modules(LServer)) of
true ->
catch mod_last_odbc:store_last_info(
UserB,
ServerB,
list_to_integer(TimeStamp),
Status);
false ->
catch mod_last:store_last_info(
UserB,
ServerB,
list_to_integer(TimeStamp),
Status)
end,
Status),
ok;
?NS_VCARD ->
case lists:member(mod_vcard_odbc,
gen_mod:loaded_modules(LServer)) of
true ->
catch mod_vcard_odbc:process_sm_iq(
From,
exmpp_jid:make(Server),
#iq{kind = request, type = set, ns = ?NS_VCARD, payload = El, iq_ns = ?NS_JABBER_CLIENT});
false ->
catch mod_vcard:process_sm_iq(
From,
exmpp_jid:make(Server),
#iq{kind = request, type = set, ns = ?NS_VCARD, payload = El, iq_ns = ?NS_JABBER_CLIENT})
end,
#iq{kind = request, type = set, ns = ?NS_VCARD, payload = El, iq_ns = ?NS_JABBER_CLIENT}),
ok;
"jabber:x:offline" ->
process_offline(Server, From, El),

View File

@ -1779,12 +1779,9 @@ stop_node(From, Host, ENode, Action, XData) ->
get_last_info(User, Server) ->
ML = lists:member(mod_last, gen_mod:loaded_modules(Server)),
MLO = lists:member(mod_last_odbc, gen_mod:loaded_modules(Server)),
case {ML, MLO} of
{true, _} -> mod_last:get_last_info(User, Server);
{false, true} -> mod_last_odbc:get_last_info(User, Server);
{false, false} -> not_found
case lists:member(mod_last, gen_mod:loaded_modules(Server)) of
true -> mod_last:get_last_info(User, Server);
false -> not_found
end.

View File

@ -176,7 +176,7 @@ get_user_roster(Items, US) ->
get_vcard_module(Server) ->
Modules = gen_mod:loaded_modules(Server),
[M || M <- Modules,
(M == mod_vcard) or (M == mod_vcard_odbc) or (M == mod_vcard_ldap)].
(M == mod_vcard) or (M == mod_vcard_ldap)].
get_rosteritem_name([], _, _) ->
<<>>;
@ -235,15 +235,14 @@ process_item(RosterItem, Host) ->
[] ->
%% Remove pending subscription by setting it
%% unsubscribed.
Mod = get_roster_mod(ServerFrom),
%% Remove pending out subscription
Mod:out_subscription(UserTo, ServerTo,
mod_roster:out_subscription(UserTo, ServerTo,
exmpp_jid:make(UserFrom, ServerFrom),
unsubscribe),
%% Remove pending in subscription
Mod:in_subscription(aaaa, UserFrom, ServerFrom,
mod_roster:in_subscription(aaaa, UserFrom, ServerFrom,
exmpp_jid:make(UserTo, ServerTo),
unsubscribe, ""),
@ -272,8 +271,6 @@ build_roster_record(User1, Server1, User2, Server2, Name2, Groups) ->
set_new_rosteritems(UserFrom, ServerFrom,
UserTo, ServerTo, ResourceTo, NameTo, GroupsFrom) ->
Mod = get_roster_mod(ServerFrom),
RIFrom = build_roster_record(UserFrom, ServerFrom,
UserTo, ServerTo, NameTo, GroupsFrom),
set_item(UserFrom, ServerFrom, ResourceTo, RIFrom),
@ -285,20 +282,20 @@ set_new_rosteritems(UserFrom, ServerFrom,
set_item(UserTo, ServerTo, undefined, RITo),
%% From requests
Mod:out_subscription(UserFrom, ServerFrom, JIDTo, subscribe),
Mod:in_subscription(aaa, UserTo, ServerTo, JIDFrom, subscribe, ""),
mod_roster:out_subscription(UserFrom, ServerFrom, JIDTo, subscribe),
mod_roster:in_subscription(aaa, UserTo, ServerTo, JIDFrom, subscribe, ""),
%% To accepts
Mod:out_subscription(UserTo, ServerTo, JIDFrom, subscribed),
Mod:in_subscription(aaa, UserFrom, ServerFrom, JIDTo, subscribed, ""),
mod_roster:out_subscription(UserTo, ServerTo, JIDFrom, subscribed),
mod_roster:in_subscription(aaa, UserFrom, ServerFrom, JIDTo, subscribed, ""),
%% To requests
Mod:out_subscription(UserTo, ServerTo, JIDFrom, subscribe),
Mod:in_subscription(aaa, UserFrom, ServerFrom, JIDTo, subscribe, ""),
mod_roster:out_subscription(UserTo, ServerTo, JIDFrom, subscribe),
mod_roster:in_subscription(aaa, UserFrom, ServerFrom, JIDTo, subscribe, ""),
%% From accepts
Mod:out_subscription(UserFrom, ServerFrom, JIDTo, subscribed),
Mod:in_subscription(aaa, UserTo, ServerTo, JIDFrom, subscribed, ""),
mod_roster:out_subscription(UserFrom, ServerFrom, JIDTo, subscribed),
mod_roster:in_subscription(aaa, UserTo, ServerTo, JIDFrom, subscribed, ""),
RIFrom.
@ -370,15 +367,13 @@ in_subscription(Acc, User, Server, JID, Type, _Reason) ->
process_subscription(in, User, Server, JID, Type, Acc).
out_subscription(UserFrom, ServerFrom, JIDTo, unsubscribed) ->
Mod = get_roster_mod(ServerFrom),
%% Remove pending out subscription
{UserTo, ServerTo, _} = jlib:short_prepd_bare_jid(JIDTo),
JIDFrom = exmpp_jid:make(UserFrom, UserTo),
Mod:out_subscription(UserTo, ServerTo, JIDFrom, unsubscribe),
mod_roster:out_subscription(UserTo, ServerTo, JIDFrom, unsubscribe),
%% Remove pending in subscription
Mod:in_subscription(aaaa, UserFrom, ServerFrom, JIDTo, unsubscribe, ""),
mod_roster:in_subscription(aaaa, UserFrom, ServerFrom, JIDTo, unsubscribe, ""),
process_subscription(out, UserFrom, ServerFrom, JIDTo, unsubscribed, false);
out_subscription(User, Server, JID, Type) ->
@ -1010,14 +1005,6 @@ shared_roster_group_parse_query(Host, Group, Query) ->
nothing
end.
%% Get the roster module for Server.
get_roster_mod(Server) ->
case lists:member(mod_roster_odbc,
gen_mod:loaded_modules(Server)) of
true -> mod_roster_odbc;
false -> mod_roster
end.
get_opt(Opts, Opt, Default) ->
case lists:keysearch(Opt, 1, Opts) of
{value, {_, Val}} ->

View File

@ -1604,7 +1604,6 @@ list_users_in_diapason(Host, Diap, Lang, URLFunc) ->
[list_given_users(Host, Sub, "../../", Lang, URLFunc)].
list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
ModLast = get_lastactivity_module(Host),
ModOffline = get_offlinemsg_module(Host),
?XE('table',
[?XE('thead',
@ -1625,7 +1624,7 @@ list_given_users(Host, Users, Prefix, Lang, URLFunc) ->
FLast =
case ejabberd_sm:get_user_resources(UserB, ServerB) of
[] ->
case ModLast:get_last_info(User, Server) of
case mod_last:get_last_info(User, Server) of
not_found ->
?T("Never");
{ok, Shift, _Status} ->
@ -1660,22 +1659,9 @@ get_offlinemsg_length(ModOffline, User, Server) ->
end.
get_offlinemsg_module(Server) ->
case [mod_offline, mod_offline_odbc] -- gen_mod:loaded_modules(Server) of
[mod_offline, mod_offline_odbc] -> none;
[mod_offline_odbc] -> mod_offline;
[mod_offline] -> mod_offline_odbc
end.
get_lastactivity_module(Server) ->
case lists:member(mod_last, gen_mod:loaded_modules(Server)) of
true -> mod_last;
_ -> mod_last_odbc
end.
get_lastactivity_menuitem_list(Server) ->
case get_lastactivity_module(Server) of
mod_last -> [{"last-activity", "Last Activity"}];
mod_last_odbc -> []
case [mod_offline] -- gen_mod:loaded_modules(Server) of
[mod_offline] -> none;
[] -> mod_offline
end.
us_to_list({User, Server}) ->
@ -1776,10 +1762,9 @@ user_info(User, Server, Query, Lang) ->
UserItems = ejabberd_hooks:run_fold(webadmin_user, list_to_binary(LServer), [],
[User, Server, Lang]),
%% Code copied from list_given_users/5:
ModLast = get_lastactivity_module(Server),
LastActivity = case ejabberd_sm:get_user_resources(UserB, ServerB) of
[] ->
case ModLast:get_last_info(UserB, ServerB) of
case mod_last:get_last_info(UserB, ServerB) of
not_found ->
?T("Never");
{ok, Shift, _Status} ->
@ -2963,9 +2948,9 @@ make_host_menu(Host, HostNodeMenu, Lang, JID) ->
HostFixed = [{"acls", "Access Control Lists"},
{"access", "Access Rules"},
{"users", "Users"},
{"online-users", "Online Users"}]
++ get_lastactivity_menuitem_list(Host) ++
[{"nodes", "Nodes", HostNodeMenu},
{"online-users", "Online Users"},
{"last-activity", "Last Activity"},
{"nodes", "Nodes", HostNodeMenu},
{"misc", "Miscelanea Options"},
{"stats", "Statistics"}]
++ get_menu_items_hook({host, Host}, Lang),