diff options
Diffstat (limited to 'src/mod_configure2.erl')
-rw-r--r-- | src/mod_configure2.erl | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/mod_configure2.erl b/src/mod_configure2.erl index b70f8fe51..0acd4a78c 100644 --- a/src/mod_configure2.erl +++ b/src/mod_configure2.erl @@ -5,7 +5,7 @@ %%% Created : 26 Oct 2003 by Alexey Shchepin <alexey@process-one.net> %%% %%% -%%% ejabberd, Copyright (C) 2002-2015 ProcessOne +%%% ejabberd, Copyright (C) 2002-2016 ProcessOne %%% %%% This program is free software; you can redistribute it and/or %%% modify it under the terms of the GNU General Public License as @@ -25,11 +25,14 @@ -module(mod_configure2). +-behaviour(ejabberd_config). + -author('alexey@process-one.net'). -behaviour(gen_mod). --export([start/2, stop/1, process_local_iq/3]). +-export([start/2, stop/1, process_local_iq/3, + mod_opt_type/1, opt_type/1]). -include("ejabberd.hrl"). -include("logger.hrl"). @@ -62,7 +65,7 @@ process_local_iq(From, To, set -> IQ#iq{type = error, sub_el = [SubEl, ?ERR_FEATURE_NOT_IMPLEMENTED]}; - %%case xml:get_tag_attr_s("type", SubEl) of + %%case fxml:get_tag_attr_s("type", SubEl) of %% "cancel" -> %% IQ#iq{type = result, %% sub_el = [{xmlelement, "query", @@ -76,7 +79,7 @@ process_local_iq(From, To, %% _ -> %% Node = %% string:tokens( - %% xml:get_tag_attr_s("node", SubEl), + %% fxml:get_tag_attr_s("node", SubEl), %% "/"), %% case set_form(Node, Lang, XData) of %% {result, Res} -> @@ -183,8 +186,7 @@ process_get(#xmlel{name = <<"last">>, attrs = Attrs}) -> {'EXIT', _Reason} -> {error, ?ERR_INTERNAL_SERVER_ERROR}; Vals -> - {MegaSecs, Secs, _MicroSecs} = now(), - TimeStamp = MegaSecs * 1000000 + Secs, + TimeStamp = p1_time_compat:system_time(seconds), Str = list_to_binary( [[jlib:integer_to_binary(TimeStamp - V), <<" ">>] || V <- Vals]), @@ -195,3 +197,21 @@ process_get(#xmlel{name = <<"last">>, attrs = Attrs}) -> %%process_get({xmlelement, Name, Attrs, SubEls}) -> %% {result, }; process_get(_) -> {error, ?ERR_BAD_REQUEST}. + +mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1; +mod_opt_type(_) -> [iqdisc]. + +opt_type(registration_watchers) -> + fun (JIDs) when is_list(JIDs) -> + lists:map(fun (J) -> + #xmlel{name = <<"jid">>, attrs = [], + children = + [{xmlcdata, iolist_to_binary(J)}]} + end, + JIDs) + end; +opt_type(welcome_message) -> + fun ({Subj, Body}) -> + {iolist_to_binary(Subj), iolist_to_binary(Body)} + end; +opt_type(_) -> [registration_watchers, welcome_message]. |