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