mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-26 16:26:24 +01:00
Merge branch 'master' of git+ssh://gitorious.process-one.net/ejabberd/mainline
This commit is contained in:
commit
7c580bbeed
@ -248,9 +248,11 @@ install: all
|
||||
#
|
||||
# Documentation
|
||||
install -d $(DOCDIR)
|
||||
install -m 644 ../doc/dev.html $(DOCDIR)
|
||||
install -m 644 ../doc/guide.html $(DOCDIR)
|
||||
install -m 644 ../doc/*.png $(DOCDIR)
|
||||
[ -f ../doc/guide.html ] \
|
||||
&& install -m 644 ../doc/dev.html $(DOCDIR) \
|
||||
&& install -m 644 ../doc/guide.html $(DOCDIR) \
|
||||
&& install -m 644 ../doc/*.png $(DOCDIR) \
|
||||
|| echo "No ../doc/guide.html was built"
|
||||
install -m 644 ../doc/*.txt $(DOCDIR)
|
||||
[ -f ../doc/guide.pdf ] \
|
||||
&& install -m 644 ../doc/guide.pdf $(DOCDIR) \
|
||||
|
@ -388,11 +388,11 @@ import_dir(Path) ->
|
||||
%%%
|
||||
|
||||
delete_expired_messages() ->
|
||||
{atomic, ok} = mod_offline:remove_expired_messages(),
|
||||
mod_offline:remove_expired_messages(),
|
||||
ok.
|
||||
|
||||
delete_old_messages(Days) ->
|
||||
{atomic, _} = mod_offline:remove_old_messages(Days),
|
||||
mod_offline:remove_old_messages(Days),
|
||||
ok.
|
||||
|
||||
|
||||
|
@ -58,14 +58,21 @@ behaviour_info(_) ->
|
||||
-include("ejabberd.hrl"). % This is used for ERROR_MSG
|
||||
|
||||
%% Returns all hosts where the table Tab is defined
|
||||
-spec all_table_hosts(atom()) ->
|
||||
-spec all_table_hosts(storage_table()) ->
|
||||
[storage_host()].
|
||||
all_table_hosts(Tab) ->
|
||||
mnesia:dirty_select(table, [{{table, {'$1', '$2'}, '_', '_'},
|
||||
TT = setelement(2, {table, {<<"hidding_from_dialyzer">>, '$2'}, '_', '_'}, {'$1', '$2'}),
|
||||
Res = (catch mnesia:dirty_select(table, [{TT,
|
||||
[{'=:=', '$2', {const, Tab}}],
|
||||
['$1']}]).
|
||||
['$1']}])),
|
||||
case Res of
|
||||
Res when is_list(Res) ->
|
||||
[HostB || HostB <- Res, is_binary(HostB)];
|
||||
_ ->
|
||||
[]
|
||||
end.
|
||||
|
||||
-spec table_info(storage_host, storage_table, atom()) ->
|
||||
-spec table_info(storage_host(), storage_table(), atom()) ->
|
||||
any().
|
||||
table_info(Host, Tab, InfoKey) ->
|
||||
Info =
|
||||
@ -108,7 +115,7 @@ table_info(Host, Tab, InfoKey) ->
|
||||
%% option() is any mnesia option
|
||||
%% columndef() defaults to text for all unspecified attributes
|
||||
|
||||
-spec create_table(atom(), storage_host(), storage_table(), #table{}) ->
|
||||
-spec create_table(atom(), storage_host(), storage_table(), list()) ->
|
||||
tuple().
|
||||
|
||||
create_table(mnesia, Host, Tab, Def) ->
|
||||
@ -130,9 +137,9 @@ define_table(Backend, Host, Name, Def) ->
|
||||
backend = Backend,
|
||||
def = Def}).
|
||||
|
||||
%% @spec (#table{}) -> [{atom(), any()}]
|
||||
%% @spec (list()) -> [{atom(), any()}]
|
||||
|
||||
-spec filter_mnesia_tabdef(#table{}) ->
|
||||
-spec filter_mnesia_tabdef(list()) ->
|
||||
[any()].
|
||||
|
||||
filter_mnesia_tabdef(TabDef) ->
|
||||
@ -202,6 +209,7 @@ dirty_read(Host, Tab, Key) ->
|
||||
| {'or', matchrule(), matchrule()}
|
||||
| {'orelse', matchrule(), matchrule()}
|
||||
| {'=', Attribute::atom(), matchvalue()}
|
||||
| {'<', Attribute::atom(), matchvalue()}
|
||||
| {'=/=', Attribute::atom(), matchvalue()}
|
||||
| {like, Attribute::atom(), matchvalue()}).
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
attributes :: [string()], % Columns
|
||||
columns :: string(), % "\"col1\", \"col2\" ,..."
|
||||
column_names :: [{string(), [string()]}], % [{string(), [string()]}] (already quoted)
|
||||
types :: [{string(), atom()}],
|
||||
types :: [{string(), atom() | tuple()}],
|
||||
host :: string()
|
||||
}).
|
||||
-record(odbc_cont, {tabdef, sql, offset = 0, limit}).
|
||||
|
@ -218,8 +218,8 @@ process_local_iq(_From, _To, #iq{type = set} = IQ_Rec) ->
|
||||
|
||||
|
||||
process_sm_iq(_From, To, #iq{type = get} = IQ_Rec) ->
|
||||
LUser = exmpp_jid:prep_node_as_list(To),
|
||||
LServer = exmpp_jid:prep_domain_as_list(To),
|
||||
LUser = exmpp_jid:prep_node(To),
|
||||
LServer = exmpp_jid:prep_domain(To),
|
||||
case get_vcard(LUser, LServer) of
|
||||
{vcard, VCard} ->
|
||||
exmpp_iq:result(IQ_Rec, VCard);
|
||||
@ -229,15 +229,16 @@ process_sm_iq(_From, To, #iq{type = get} = IQ_Rec) ->
|
||||
process_sm_iq(From, _To, #iq{type = set, payload = Request} = IQ_Rec) ->
|
||||
User = exmpp_jid:node_as_list(From),
|
||||
LServer = exmpp_jid:prep_domain_as_list(From),
|
||||
LServerB = exmpp_jid:prep_domain(From),
|
||||
case ?IS_MY_HOST(LServer) of
|
||||
true ->
|
||||
set_vcard(User, LServer, Request),
|
||||
set_vcard(User, LServer, LServerB, Request),
|
||||
exmpp_iq:result(IQ_Rec);
|
||||
false ->
|
||||
exmpp_iq:error(IQ_Rec, 'not-allowed')
|
||||
end.
|
||||
|
||||
%% @spec (User::string(), Host::string()) -> {vcard, xmlel()} | novcard
|
||||
%% @spec (User::binary(), Host::binary()) -> {vcard, xmlel()} | novcard
|
||||
get_vcard(User, Host) ->
|
||||
US = {User, Host},
|
||||
case gen_storage:dirty_read(Host, {vcard, US}) of
|
||||
@ -253,7 +254,7 @@ get_vcard(User, Host) ->
|
||||
end.
|
||||
|
||||
|
||||
set_vcard(User, LServer, VCARD) ->
|
||||
set_vcard(User, LServer, LServerB, VCARD) ->
|
||||
FN = exmpp_xml:get_path(VCARD,
|
||||
[{element, 'FN'}, cdata_as_list]),
|
||||
Family = exmpp_xml:get_path(VCARD,
|
||||
@ -301,14 +302,14 @@ set_vcard(User, LServer, VCARD) ->
|
||||
|
||||
US = {LUser, LServer},
|
||||
|
||||
VcardToStore = case gen_storage:table_info(LServer, vcard, backend) of
|
||||
VcardToStore = case gen_storage:table_info(LServerB, vcard, backend) of
|
||||
mnesia -> VCARD;
|
||||
odbc -> lists:flatten(exmpp_xml:document_to_list(VCARD))
|
||||
end,
|
||||
|
||||
F = fun() ->
|
||||
gen_storage:write(LServer, #vcard{user_host = US, vcard = VcardToStore}),
|
||||
gen_storage:write(LServer,
|
||||
gen_storage:write(LServerB, #vcard{user_host = US, vcard = VcardToStore}),
|
||||
gen_storage:write(LServerB,
|
||||
#vcard_search{user_host=US,
|
||||
username = User, lusername = LUser,
|
||||
fn = FN, lfn = LFN,
|
||||
@ -324,8 +325,8 @@ set_vcard(User, LServer, VCARD) ->
|
||||
orgunit = OrgUnit, lorgunit = LOrgUnit
|
||||
})
|
||||
end,
|
||||
gen_storage:transaction(LServer, vcard, F),
|
||||
LServerB = list_to_binary(LServer),
|
||||
gen_storage:transaction(LServerB, vcard, F),
|
||||
ejabberd_hooks:run(vcard_set, LServerB, [list_to_binary(LUser), LServerB, VCARD])
|
||||
catch
|
||||
_ ->
|
||||
@ -729,10 +730,10 @@ remove_user(User, Server) when is_binary(User), is_binary(Server) ->
|
||||
LServer = binary_to_list(exmpp_stringprep:nameprep(Server)),
|
||||
US = {LUser, LServer},
|
||||
F = fun() ->
|
||||
gen_storage:delete(LServer, {vcard, US}),
|
||||
gen_storage:delete(LServer, {vcard_search, US})
|
||||
gen_storage:delete(Server, {vcard, US}),
|
||||
gen_storage:delete(Server, {vcard_search, US})
|
||||
end,
|
||||
gen_storage:transaction(LServer, vcard, F).
|
||||
gen_storage:transaction(Server, vcard, F).
|
||||
|
||||
|
||||
%%%
|
||||
@ -892,6 +893,7 @@ get_user_photo(User, Host) ->
|
||||
|
||||
user_queue_parse_query(US, Query) ->
|
||||
{User, Server} = US,
|
||||
?INFO_MSG("Query vcard: ~p", [Query]), %+++
|
||||
case lists:keysearch("removevcard", 1, Query) of
|
||||
{value, _} ->
|
||||
case remove_user(list_to_binary(User), list_to_binary(Server)) of
|
||||
|
@ -466,10 +466,6 @@ search(LServer, Data) ->
|
||||
MatchSpec = make_matchspec(LServer, Data),
|
||||
AllowReturnAll = gen_mod:get_module_opt(LServer, ?MODULE,
|
||||
allow_return_all, false),
|
||||
if
|
||||
(MatchSpec == "") and (not AllowReturnAll) ->
|
||||
[];
|
||||
true ->
|
||||
Limit = case gen_mod:get_module_opt(LServer, ?MODULE,
|
||||
matches, ?JUD_MATCHES) of
|
||||
infinity ->
|
||||
@ -491,7 +487,6 @@ search(LServer, Data) ->
|
||||
Error ->
|
||||
?ERROR_MSG("~p", [Error]),
|
||||
[]
|
||||
end
|
||||
end.
|
||||
|
||||
|
||||
@ -500,12 +495,7 @@ make_matchspec(LServer, Data) ->
|
||||
filter_fields(Data, ["host = '", Host, "'"], LServer).
|
||||
|
||||
filter_fields([], Match, _LServer) ->
|
||||
case Match of
|
||||
"" ->
|
||||
"";
|
||||
_ ->
|
||||
[" where ", Match]
|
||||
end;
|
||||
[" where ", Match];
|
||||
filter_fields([{SVar, [Val]} | Ds], Match, LServer)
|
||||
when is_list(Val) and (Val /= "") ->
|
||||
LVal = exmpp_stringprep:to_lower(Val),
|
||||
@ -539,12 +529,7 @@ make_val(Match, Field, Val) ->
|
||||
SVal = ejabberd_odbc:escape(Val),
|
||||
[Field, " = '", SVal, "'"]
|
||||
end,
|
||||
case Match of
|
||||
"" ->
|
||||
Condition;
|
||||
_ ->
|
||||
[Match, " and ", Condition]
|
||||
end.
|
||||
[Match, " and ", Condition].
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user