25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-24 17:29:28 +01:00
xmpp.chapril.org-ejabberd/src/mod_time.erl

49 lines
1.2 KiB
Erlang
Raw Normal View History

%%%----------------------------------------------------------------------
%%% File : mod_time.erl
%%% Author : Alexey Shchepin <alexey@sevcom.net>
%%% Purpose :
%%% Created : 18 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
%%% 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.