%%%----------------------------------------------------------------------
%%% File : mod_version.erl
%%% Author : Alexey Shchepin <alexey@sevcom.net>
-%%% Purpose :
+%%% Purpose : XEP-0092: Software Version
%%% Created : 18 Jan 2003 by Alexey Shchepin <alexey@sevcom.net>
-%%% Id : $Id$
%%%----------------------------------------------------------------------
-module(mod_version).
-author('alexey@sevcom.net').
--vsn('$Revision$ ').
-behaviour(gen_mod).
set ->
IQ#iq{type = error, sub_el = [SubEl, ?ERR_NOT_ALLOWED]};
get ->
- OSType = case os:type() of
- {Osfamily, Osname} ->
- atom_to_list(Osfamily) ++ "/" ++
- atom_to_list(Osname);
- Osfamily ->
- atom_to_list(Osfamily)
- end,
- OSVersion = case os:version() of
- {Major, Minor, Release} ->
- lists:flatten(
- io_lib:format("~w.~w.~w",
- [Major, Minor, Release]));
- VersionString ->
- VersionString
- end,
- OS = OSType ++ " " ++ OSVersion,
+ Host = To#jid.server,
+ OS = case gen_mod:get_module_opt(Host, ?MODULE, show_os, true) of
+ true -> [get_os()];
+ false -> []
+ end,
IQ#iq{type = result,
sub_el = [{xmlelement, "query",
[{"xmlns", ?NS_VERSION}],
[{xmlelement, "name", [],
[{xmlcdata, "ejabberd"}]},
{xmlelement, "version", [],
- [{xmlcdata, ?VERSION}]},
- {xmlelement, "os", [],
- [{xmlcdata, OS}]}
- ]}]}
+ [{xmlcdata, ?VERSION}]}
+ ] ++ OS
+ }]}
end.
+get_os() ->
+ OSType = case os:type() of
+ {Osfamily, Osname} ->
+ atom_to_list(Osfamily) ++ "/" ++
+ atom_to_list(Osname);
+ Osfamily ->
+ atom_to_list(Osfamily)
+ end,
+ OSVersion = case os:version() of
+ {Major, Minor, Release} ->
+ lists:flatten(
+ io_lib:format("~w.~w.~w",
+ [Major, Minor, Release]));
+ VersionString ->
+ VersionString
+ end,
+ OS = OSType ++ " " ++ OSVersion,
+ {xmlelement, "os", [], [{xmlcdata, OS}]}.