diff options
Diffstat (limited to 'src/mod_time.erl')
-rw-r--r-- | src/mod_time.erl | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/src/mod_time.erl b/src/mod_time.erl index c82fde41c..8bfe9f9f9 100644 --- a/src/mod_time.erl +++ b/src/mod_time.erl @@ -6,7 +6,7 @@ %%% Created : 18 Jan 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 @@ -28,12 +28,12 @@ -author('alexey@process-one.net'). --behaviour(gen_mod). +-protocol({xep, 202, '2.0'}). --export([start/2, stop/1, process_local_iq90/3, - process_local_iq/3]). +-behaviour(gen_mod). - % TODO: Remove once XEP-0090 is Obsolete +-export([start/2, stop/1, process_local_iq/3, + mod_opt_type/1]). -include("ejabberd.hrl"). -include("logger.hrl"). @@ -44,43 +44,20 @@ start(Host, Opts) -> IQDisc = gen_mod:get_opt(iqdisc, Opts, fun gen_iq_handler:check_type/1, one_queue), gen_iq_handler:add_iq_handler(ejabberd_local, Host, - ?NS_TIME90, ?MODULE, process_local_iq90, - IQDisc), - gen_iq_handler:add_iq_handler(ejabberd_local, Host, ?NS_TIME, ?MODULE, process_local_iq, IQDisc). stop(Host) -> gen_iq_handler:remove_iq_handler(ejabberd_local, Host, - ?NS_TIME90), - gen_iq_handler:remove_iq_handler(ejabberd_local, Host, ?NS_TIME). -%% TODO: Remove this function once XEP-0090 is Obsolete -process_local_iq90(_From, _To, - #iq{type = Type, sub_el = SubEl} = IQ) -> - case Type of - set -> - IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]}; - get -> - UTC = jlib:timestamp_to_iso(calendar:universal_time()), - IQ#iq{type = result, - sub_el = - [#xmlel{name = <<"query">>, - attrs = [{<<"xmlns">>, ?NS_TIME90}], - children = - [#xmlel{name = <<"utc">>, attrs = [], - children = [{xmlcdata, UTC}]}]}]} - end. - process_local_iq(_From, _To, #iq{type = Type, sub_el = SubEl} = IQ) -> case Type of set -> IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]}; get -> - Now = now(), - Now_universal = calendar:now_to_universal_time(Now), - Now_local = calendar:now_to_local_time(Now), + Now_universal = calendar:universal_time(), + Now_local = calendar:universal_time_to_local_time(Now_universal), {UTC, UTC_diff} = jlib:timestamp_to_iso(Now_universal, utc), Seconds_diff = @@ -107,3 +84,6 @@ process_local_iq(_From, _To, sign(N) when N < 0 -> <<"-">>; sign(_) -> <<"+">>. + +mod_opt_type(iqdisc) -> fun gen_iq_handler:check_type/1; +mod_opt_type(_) -> [iqdisc]. |