%%%---------------------------------------------------------------------- %%% File : mod_time.erl %%% Author : Alexey Shchepin %%% Purpose : %%% Created : 18 Jan 2003 by Alexey Shchepin %%% Id : $Id$ %%%---------------------------------------------------------------------- -module(mod_time). -author('alexey@sevcom.net'). -vsn('$Revision$ '). -behaviour(gen_mod). -export([start/1, stop/0, process_local_iq/3]). -include("ejabberd.hrl"). -include("namespaces.hrl"). start(Opts) -> IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue), gen_iq_handler:add_iq_handler(ejabberd_local, ?NS_TIME, ?MODULE, process_local_iq, IQDisc). stop() -> gen_iq_handler:remove_iq_handler(ejabberd_local, ?NS_TIME). process_local_iq(From, To, {iq, ID, Type, XMLNS, SubEl}) -> case Type of set -> {iq, ID, error, XMLNS, [SubEl, {xmlelement, "error", [{"code", "405"}], [{xmlcdata, "Not Allowed"}]}]}; get -> UTC = jlib:timestamp_to_iso(calendar:universal_time()), {iq, ID, result, XMLNS, [{xmlelement, "query", [{"xmlns", ?NS_TIME}], [{xmlelement, "utc", [], [{xmlcdata, UTC}]} ]}]} end.