25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-10-09 15:06:54 +02:00

Add announcement of offline feature to service discovery (EJAB-234)

SVN Revision: 2344
This commit is contained in:
Badlop 2009-06-30 16:51:15 +00:00
parent 35dc60c534
commit f145a32b79
2 changed files with 45 additions and 0 deletions

View File

@ -35,6 +35,7 @@
store_packet/3,
resend_offline_messages/2,
pop_offline_messages/3,
get_sm_features/5,
remove_expired_messages/0,
remove_old_messages/1,
remove_user/2,
@ -69,6 +70,10 @@ start(Host, Opts) ->
?MODULE, remove_user, 50),
ejabberd_hooks:add(anonymous_purge_hook, Host,
?MODULE, remove_user, 50),
ejabberd_hooks:add(disco_sm_features, Host,
?MODULE, get_sm_features, 50),
ejabberd_hooks:add(disco_local_features, Host,
?MODULE, get_sm_features, 50),
ejabberd_hooks:add(webadmin_page_host, Host,
?MODULE, webadmin_page, 50),
ejabberd_hooks:add(webadmin_user, Host,
@ -144,6 +149,8 @@ stop(Host) ->
?MODULE, remove_user, 50),
ejabberd_hooks:delete(anonymous_purge_hook, Host,
?MODULE, remove_user, 50),
ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE, get_sm_features, 50),
ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, get_sm_features, 50),
ejabberd_hooks:delete(webadmin_page_host, Host,
?MODULE, webadmin_page, 50),
ejabberd_hooks:delete(webadmin_user, Host,
@ -154,6 +161,21 @@ stop(Host) ->
exit(whereis(Proc), stop),
{wait, Proc}.
get_sm_features(Acc, _From, _To, "", _Lang) ->
Feats = case Acc of
{result, I} -> I;
_ -> []
end,
{result, Feats ++ [?NS_FEATURE_MSGOFFLINE]};
get_sm_features(_Acc, _From, _To, ?NS_FEATURE_MSGOFFLINE, _Lang) ->
%% override all lesser features...
{result, []};
get_sm_features(Acc, _From, _To, _Node, _Lang) ->
Acc.
store_packet(From, To, Packet) ->
Type = xml:get_tag_attr_s("type", Packet),
if
@ -317,6 +339,7 @@ pop_offline_messages(Ls, User, Server) ->
Ls
end.
remove_expired_messages() ->
TimeStamp = now(),
F = fun() ->

View File

@ -36,6 +36,7 @@
stop/1,
store_packet/3,
pop_offline_messages/3,
get_sm_features/5,
remove_user/2,
webadmin_page/3,
webadmin_user/4,
@ -63,6 +64,10 @@ start(Host, Opts) ->
?MODULE, remove_user, 50),
ejabberd_hooks:add(anonymous_purge_hook, Host,
?MODULE, remove_user, 50),
ejabberd_hooks:add(disco_sm_features, Host,
?MODULE, get_sm_features, 50),
ejabberd_hooks:add(disco_local_features, Host,
?MODULE, get_sm_features, 50),
ejabberd_hooks:add(webadmin_page_host, Host,
?MODULE, webadmin_page, 50),
ejabberd_hooks:add(webadmin_user, Host,
@ -155,6 +160,8 @@ stop(Host) ->
?MODULE, remove_user, 50),
ejabberd_hooks:delete(anonymous_purge_hook, Host,
?MODULE, remove_user, 50),
ejabberd_hooks:delete(disco_sm_features, Host, ?MODULE, get_sm_features, 50),
ejabberd_hooks:delete(disco_local_features, Host, ?MODULE, get_sm_features, 50),
ejabberd_hooks:delete(webadmin_page_host, Host,
?MODULE, webadmin_page, 50),
ejabberd_hooks:delete(webadmin_user, Host,
@ -165,6 +172,21 @@ stop(Host) ->
exit(whereis(Proc), stop),
ok.
get_sm_features(Acc, _From, _To, "", _Lang) ->
Feats = case Acc of
{result, I} -> I;
_ -> []
end,
{result, Feats ++ [?NS_FEATURE_MSGOFFLINE]};
get_sm_features(_Acc, _From, _To, ?NS_FEATURE_MSGOFFLINE, _Lang) ->
%% override all lesser features...
{result, []};
get_sm_features(Acc, _From, _To, _Node, _Lang) ->
Acc.
store_packet(From, To, Packet) ->
Type = xml:get_tag_attr_s("type", Packet),
if