Copy header files from current ejabberd master git branch.
This commit is contained in:
parent
203c316300
commit
c331365b97
|
@ -1,6 +1,6 @@
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%%
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
|
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
%%% modify it under the terms of the GNU General Public License as
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
@ -19,18 +19,27 @@
|
||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-record(adhoc_request, {lang,
|
-record(adhoc_request,
|
||||||
node,
|
{
|
||||||
sessionid,
|
lang = <<"">> :: binary(),
|
||||||
action,
|
node = <<"">> :: binary(),
|
||||||
xdata,
|
sessionid = <<"">> :: binary(),
|
||||||
others}).
|
action = <<"">> :: binary(),
|
||||||
|
xdata = false :: false | xmlel(),
|
||||||
|
others = [] :: [xmlel()]
|
||||||
|
}).
|
||||||
|
|
||||||
-record(adhoc_response, {lang,
|
-record(adhoc_response,
|
||||||
node,
|
{
|
||||||
sessionid,
|
lang = <<"">> :: binary(),
|
||||||
status,
|
node = <<"">> :: binary(),
|
||||||
defaultaction = "",
|
sessionid = <<"">> :: binary(),
|
||||||
actions = [],
|
status :: atom(),
|
||||||
notes = [],
|
defaultaction = <<"">> :: binary(),
|
||||||
elements = []}).
|
actions = [] :: [binary()],
|
||||||
|
notes = [] :: [{binary(), binary()}],
|
||||||
|
elements = [] :: [xmlel()]
|
||||||
|
}).
|
||||||
|
|
||||||
|
-type adhoc_request() :: #adhoc_request{}.
|
||||||
|
-type adhoc_response() :: #adhoc_response{}.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%%
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
|
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
%%% modify it under the terms of the GNU General Public License as
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
@ -21,44 +21,57 @@
|
||||||
|
|
||||||
%% This macro returns a string of the ejabberd version running, e.g. "2.3.4"
|
%% This macro returns a string of the ejabberd version running, e.g. "2.3.4"
|
||||||
%% If the ejabberd application description isn't loaded, returns atom: undefined
|
%% If the ejabberd application description isn't loaded, returns atom: undefined
|
||||||
-define(VERSION, element(2, application:get_key(ejabberd,vsn))).
|
-define(VERSION, ejabberd_config:get_version()).
|
||||||
|
|
||||||
-define(MYHOSTS, ejabberd_config:get_global_option(hosts)).
|
-define(MYHOSTS, ejabberd_config:get_myhosts()).
|
||||||
-define(MYNAME, hd(ejabberd_config:get_global_option(hosts))).
|
|
||||||
-define(MYLANG, ejabberd_config:get_global_option(language)).
|
|
||||||
|
|
||||||
-define(MSGS_DIR, "msgs").
|
-define(MYNAME, hd(ejabberd_config:get_myhosts())).
|
||||||
-define(CONFIG_PATH, "ejabberd.cfg").
|
|
||||||
-define(LOG_PATH, "ejabberd.log").
|
|
||||||
|
|
||||||
-define(EJABBERD_URI, "http://www.process-one.net/en/ejabberd/").
|
-define(MYLANG, ejabberd_config:get_mylang()).
|
||||||
|
|
||||||
|
-define(MSGS_DIR, <<"msgs">>).
|
||||||
|
|
||||||
|
-define(CONFIG_PATH, <<"ejabberd.cfg">>).
|
||||||
|
|
||||||
|
-define(LOG_PATH, <<"ejabberd.log">>).
|
||||||
|
|
||||||
|
-define(EJABBERD_URI, <<"http://www.process-one.net/en/ejabberd/">>).
|
||||||
|
|
||||||
-define(S2STIMEOUT, 600000).
|
-define(S2STIMEOUT, 600000).
|
||||||
|
|
||||||
%%-define(DBGFSM, true).
|
%%-define(DBGFSM, true).
|
||||||
|
|
||||||
-record(scram, {storedkey, serverkey, salt, iterationcount}).
|
-record(scram,
|
||||||
|
{storedkey = <<"">>,
|
||||||
|
serverkey = <<"">>,
|
||||||
|
salt = <<"">>,
|
||||||
|
iterationcount = 0 :: integer()}).
|
||||||
|
|
||||||
|
-type scram() :: #scram{}.
|
||||||
|
|
||||||
-define(SCRAM_DEFAULT_ITERATION_COUNT, 4096).
|
-define(SCRAM_DEFAULT_ITERATION_COUNT, 4096).
|
||||||
|
|
||||||
%% ---------------------------------
|
%% ---------------------------------
|
||||||
%% Logging mechanism
|
%% Logging mechanism
|
||||||
|
|
||||||
%% Print in standard output
|
%% Print in standard output
|
||||||
-define(PRINT(Format, Args),
|
-define(PRINT(Format, Args), io:format(Format, Args)).
|
||||||
io:format(Format, Args)).
|
|
||||||
|
|
||||||
-define(DEBUG(Format, Args),
|
-define(DEBUG(Format, Args),
|
||||||
ejabberd_logger:debug_msg(?MODULE,?LINE,Format, Args)).
|
ejabberd_logger:debug_msg(?MODULE, ?LINE, Format,
|
||||||
|
Args)).
|
||||||
|
|
||||||
-define(INFO_MSG(Format, Args),
|
-define(INFO_MSG(Format, Args),
|
||||||
ejabberd_logger:info_msg(?MODULE,?LINE,Format, Args)).
|
ejabberd_logger:info_msg(?MODULE, ?LINE, Format, Args)).
|
||||||
|
|
||||||
-define(WARNING_MSG(Format, Args),
|
-define(WARNING_MSG(Format, Args),
|
||||||
ejabberd_logger:warning_msg(?MODULE,?LINE,Format, Args)).
|
ejabberd_logger:warning_msg(?MODULE, ?LINE, Format,
|
||||||
|
Args)).
|
||||||
|
|
||||||
-define(ERROR_MSG(Format, Args),
|
-define(ERROR_MSG(Format, Args),
|
||||||
ejabberd_logger:error_msg(?MODULE,?LINE,Format, Args)).
|
ejabberd_logger:error_msg(?MODULE, ?LINE, Format,
|
||||||
|
Args)).
|
||||||
|
|
||||||
-define(CRITICAL_MSG(Format, Args),
|
-define(CRITICAL_MSG(Format, Args),
|
||||||
ejabberd_logger:critical_msg(?MODULE,?LINE,Format, Args)).
|
ejabberd_logger:critical_msg(?MODULE, ?LINE, Format,
|
||||||
|
Args)).
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%%
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
|
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
%%% modify it under the terms of the GNU General Public License as
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
@ -19,10 +19,32 @@
|
||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-record(ejabberd_commands, {name, tags = [],
|
-type aterm() :: {atom(), atype()}.
|
||||||
desc = "", longdesc = "",
|
-type atype() :: integer | string | binary |
|
||||||
module, function,
|
{tuple, [aterm()]} | {list, aterm()}.
|
||||||
args = [], result = rescode}).
|
-type rterm() :: {atom(), rtype()}.
|
||||||
|
-type rtype() :: integer | string | atom |
|
||||||
|
{tuple, [rterm()]} | {list, rterm()} |
|
||||||
|
rescode | restuple.
|
||||||
|
|
||||||
|
-record(ejabberd_commands,
|
||||||
|
{name :: atom(),
|
||||||
|
tags = [] :: [atom()] | '_' | '$2',
|
||||||
|
desc = "" :: string() | '_' | '$3',
|
||||||
|
longdesc = "" :: string() | '_',
|
||||||
|
module :: atom(),
|
||||||
|
function :: atom(),
|
||||||
|
args = [] :: [aterm()] | '_' | '$1' | '$2',
|
||||||
|
result = {res, rescode} :: rterm() | '_' | '$2'}).
|
||||||
|
|
||||||
|
-type ejabberd_commands() :: #ejabberd_commands{name :: atom(),
|
||||||
|
tags :: [atom()],
|
||||||
|
desc :: string(),
|
||||||
|
longdesc :: string(),
|
||||||
|
module :: atom(),
|
||||||
|
function :: atom(),
|
||||||
|
args :: [aterm()],
|
||||||
|
result :: rterm()}.
|
||||||
|
|
||||||
%% @type ejabberd_commands() = #ejabberd_commands{
|
%% @type ejabberd_commands() = #ejabberd_commands{
|
||||||
%% name = atom(),
|
%% name = atom(),
|
||||||
|
@ -50,3 +72,4 @@
|
||||||
|
|
||||||
%% @type rterm() = {Name::atom(), Type::rtype()}.
|
%% @type rterm() = {Name::atom(), Type::rtype()}.
|
||||||
%% A result term is a tuple with the term name and the term type.
|
%% A result term is a tuple with the term name and the term type.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%%
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
|
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
%%% modify it under the terms of the GNU General Public License as
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
@ -19,10 +19,16 @@
|
||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-record(config, {key, value}).
|
-record(config, {key :: any(), value :: any()}).
|
||||||
-record(local_config, {key, value}).
|
|
||||||
-record(state, {opts = [],
|
-record(local_config, {key :: any(), value :: any()}).
|
||||||
hosts = [],
|
|
||||||
override_local = false,
|
-type config() :: #config{}.
|
||||||
override_global = false,
|
-type local_config() :: #local_config{}.
|
||||||
override_acls = false}).
|
|
||||||
|
-record(state,
|
||||||
|
{opts = [] :: [acl:acl() | config() | local_config()],
|
||||||
|
hosts = [] :: [binary()],
|
||||||
|
override_local = false :: boolean(),
|
||||||
|
override_global = false :: boolean(),
|
||||||
|
override_acls = false :: boolean()}).
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%%
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
|
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
%%% modify it under the terms of the GNU General Public License as
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
@ -20,6 +20,9 @@
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-define(STATUS_SUCCESS, 0).
|
-define(STATUS_SUCCESS, 0).
|
||||||
|
|
||||||
-define(STATUS_ERROR, 1).
|
-define(STATUS_ERROR, 1).
|
||||||
|
|
||||||
-define(STATUS_USAGE, 2).
|
-define(STATUS_USAGE, 2).
|
||||||
|
|
||||||
-define(STATUS_BADRPC, 3).
|
-define(STATUS_BADRPC, 3).
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%%
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
|
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
%%% modify it under the terms of the GNU General Public License as
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
@ -19,318 +19,687 @@
|
||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-define(NS_DISCO_ITEMS, "http://jabber.org/protocol/disco#items").
|
|
||||||
-define(NS_DISCO_INFO, "http://jabber.org/protocol/disco#info").
|
|
||||||
-define(NS_VCARD, "vcard-temp").
|
|
||||||
-define(NS_VCARD_UPDATE, "vcard-temp:x:update").
|
|
||||||
-define(NS_AUTH, "jabber:iq:auth").
|
|
||||||
-define(NS_AUTH_ERROR, "jabber:iq:auth:error").
|
|
||||||
-define(NS_REGISTER, "jabber:iq:register").
|
|
||||||
-define(NS_SEARCH, "jabber:iq:search").
|
|
||||||
-define(NS_ROSTER, "jabber:iq:roster").
|
|
||||||
-define(NS_ROSTER_VER, "urn:xmpp:features:rosterver").
|
|
||||||
-define(NS_PRIVACY, "jabber:iq:privacy").
|
|
||||||
-define(NS_BLOCKING, "urn:xmpp:blocking").
|
|
||||||
-define(NS_PRIVATE, "jabber:iq:private").
|
|
||||||
-define(NS_VERSION, "jabber:iq:version").
|
|
||||||
-define(NS_TIME90, "jabber:iq:time"). % TODO: Remove once XEP-0090 is Obsolete
|
|
||||||
-define(NS_TIME, "urn:xmpp:time").
|
|
||||||
-define(NS_LAST, "jabber:iq:last").
|
|
||||||
-define(NS_XDATA, "jabber:x:data").
|
|
||||||
-define(NS_IQDATA, "jabber:iq:data").
|
|
||||||
-define(NS_DELAY91, "jabber:x:delay"). % TODO: Remove once XEP-0091 is Obsolete
|
|
||||||
-define(NS_DELAY, "urn:xmpp:delay").
|
|
||||||
-define(NS_EXPIRE, "jabber:x:expire").
|
|
||||||
-define(NS_EVENT, "jabber:x:event").
|
|
||||||
-define(NS_CHATSTATES, "http://jabber.org/protocol/chatstates").
|
|
||||||
-define(NS_XCONFERENCE, "jabber:x:conference").
|
|
||||||
-define(NS_STATS, "http://jabber.org/protocol/stats").
|
|
||||||
-define(NS_MUC, "http://jabber.org/protocol/muc").
|
|
||||||
-define(NS_MUC_USER, "http://jabber.org/protocol/muc#user").
|
|
||||||
-define(NS_MUC_ADMIN, "http://jabber.org/protocol/muc#admin").
|
|
||||||
-define(NS_MUC_OWNER, "http://jabber.org/protocol/muc#owner").
|
|
||||||
-define(NS_MUC_UNIQUE, "http://jabber.org/protocol/muc#unique").
|
|
||||||
-define(NS_PUBSUB, "http://jabber.org/protocol/pubsub").
|
|
||||||
-define(NS_PUBSUB_EVENT, "http://jabber.org/protocol/pubsub#event").
|
|
||||||
-define(NS_PUBSUB_OWNER, "http://jabber.org/protocol/pubsub#owner").
|
|
||||||
-define(NS_PUBSUB_NMI, "http://jabber.org/protocol/pubsub#node-meta-info").
|
|
||||||
-define(NS_PUBSUB_ERRORS,"http://jabber.org/protocol/pubsub#errors").
|
|
||||||
-define(NS_PUBSUB_NODE_CONFIG, "http://jabber.org/protocol/pubsub#node_config").
|
|
||||||
-define(NS_PUBSUB_SUB_OPTIONS, "http://jabber.org/protocol/pubsub#subscribe_options").
|
|
||||||
-define(NS_PUBSUB_SUB_AUTH, "http://jabber.org/protocol/pubsub#subscribe_authorization").
|
|
||||||
-define(NS_PUBSUB_GET_PENDING, "http://jabber.org/protocol/pubsub#get-pending").
|
|
||||||
-define(NS_COMMANDS, "http://jabber.org/protocol/commands").
|
|
||||||
-define(NS_BYTESTREAMS, "http://jabber.org/protocol/bytestreams").
|
|
||||||
-define(NS_ADMIN, "http://jabber.org/protocol/admin").
|
|
||||||
-define(NS_SERVERINFO, "http://jabber.org/network/serverinfo").
|
|
||||||
|
|
||||||
-define(NS_RSM, "http://jabber.org/protocol/rsm").
|
-define(NS_DISCO_ITEMS,
|
||||||
-define(NS_EJABBERD_CONFIG, "ejabberd:config").
|
<<"http://jabber.org/protocol/disco#items">>).
|
||||||
|
|
||||||
-define(NS_STREAM, "http://etherx.jabber.org/streams").
|
-define(NS_DISCO_INFO,
|
||||||
|
<<"http://jabber.org/protocol/disco#info">>).
|
||||||
|
|
||||||
-define(NS_STANZAS, "urn:ietf:params:xml:ns:xmpp-stanzas").
|
-define(NS_VCARD, <<"vcard-temp">>).
|
||||||
-define(NS_STREAMS, "urn:ietf:params:xml:ns:xmpp-streams").
|
|
||||||
|
|
||||||
-define(NS_TLS, "urn:ietf:params:xml:ns:xmpp-tls").
|
-define(NS_VCARD_UPDATE, <<"vcard-temp:x:update">>).
|
||||||
-define(NS_SASL, "urn:ietf:params:xml:ns:xmpp-sasl").
|
|
||||||
-define(NS_SESSION, "urn:ietf:params:xml:ns:xmpp-session").
|
|
||||||
-define(NS_BIND, "urn:ietf:params:xml:ns:xmpp-bind").
|
|
||||||
|
|
||||||
-define(NS_FEATURE_IQAUTH, "http://jabber.org/features/iq-auth").
|
-define(NS_AUTH, <<"jabber:iq:auth">>).
|
||||||
-define(NS_FEATURE_IQREGISTER, "http://jabber.org/features/iq-register").
|
|
||||||
-define(NS_FEATURE_COMPRESS, "http://jabber.org/features/compress").
|
|
||||||
-define(NS_FEATURE_MSGOFFLINE, "msgoffline").
|
|
||||||
|
|
||||||
-define(NS_COMPRESS, "http://jabber.org/protocol/compress").
|
-define(NS_AUTH_ERROR, <<"jabber:iq:auth:error">>).
|
||||||
|
|
||||||
-define(NS_CAPS, "http://jabber.org/protocol/caps").
|
-define(NS_REGISTER, <<"jabber:iq:register">>).
|
||||||
-define(NS_SHIM, "http://jabber.org/protocol/shim").
|
|
||||||
-define(NS_ADDRESS, "http://jabber.org/protocol/address").
|
|
||||||
|
|
||||||
%% CAPTCHA related NSes.
|
-define(NS_SEARCH, <<"jabber:iq:search">>).
|
||||||
-define(NS_OOB, "jabber:x:oob").
|
|
||||||
-define(NS_CAPTCHA, "urn:xmpp:captcha").
|
-define(NS_ROSTER, <<"jabber:iq:roster">>).
|
||||||
-define(NS_MEDIA, "urn:xmpp:media-element").
|
|
||||||
-define(NS_BOB, "urn:xmpp:bob").
|
-define(NS_ROSTER_VER,
|
||||||
|
<<"urn:xmpp:features:rosterver">>).
|
||||||
|
|
||||||
|
-define(NS_PRIVACY, <<"jabber:iq:privacy">>).
|
||||||
|
|
||||||
|
-define(NS_BLOCKING, <<"urn:xmpp:blocking">>).
|
||||||
|
|
||||||
|
-define(NS_PRIVATE, <<"jabber:iq:private">>).
|
||||||
|
|
||||||
|
-define(NS_VERSION, <<"jabber:iq:version">>).
|
||||||
|
|
||||||
|
-define(NS_TIME90, <<"jabber:iq:time">>).
|
||||||
|
|
||||||
|
-define(NS_TIME, <<"urn:xmpp:time">>).
|
||||||
|
|
||||||
|
-define(NS_LAST, <<"jabber:iq:last">>).
|
||||||
|
|
||||||
|
-define(NS_XDATA, <<"jabber:x:data">>).
|
||||||
|
|
||||||
|
-define(NS_IQDATA, <<"jabber:iq:data">>).
|
||||||
|
|
||||||
|
-define(NS_DELAY91, <<"jabber:x:delay">>).
|
||||||
|
|
||||||
|
-define(NS_DELAY, <<"urn:xmpp:delay">>).
|
||||||
|
|
||||||
|
-define(NS_EXPIRE, <<"jabber:x:expire">>).
|
||||||
|
|
||||||
|
-define(NS_EVENT, <<"jabber:x:event">>).
|
||||||
|
|
||||||
|
-define(NS_CHATSTATES,
|
||||||
|
<<"http://jabber.org/protocol/chatstates">>).
|
||||||
|
|
||||||
|
-define(NS_XCONFERENCE, <<"jabber:x:conference">>).
|
||||||
|
|
||||||
|
-define(NS_STATS,
|
||||||
|
<<"http://jabber.org/protocol/stats">>).
|
||||||
|
|
||||||
|
-define(NS_MUC, <<"http://jabber.org/protocol/muc">>).
|
||||||
|
|
||||||
|
-define(NS_MUC_USER,
|
||||||
|
<<"http://jabber.org/protocol/muc#user">>).
|
||||||
|
|
||||||
|
-define(NS_MUC_ADMIN,
|
||||||
|
<<"http://jabber.org/protocol/muc#admin">>).
|
||||||
|
|
||||||
|
-define(NS_MUC_OWNER,
|
||||||
|
<<"http://jabber.org/protocol/muc#owner">>).
|
||||||
|
|
||||||
|
-define(NS_MUC_UNIQUE,
|
||||||
|
<<"http://jabber.org/protocol/muc#unique">>).
|
||||||
|
|
||||||
|
-define(NS_PUBSUB,
|
||||||
|
<<"http://jabber.org/protocol/pubsub">>).
|
||||||
|
|
||||||
|
-define(NS_PUBSUB_EVENT,
|
||||||
|
<<"http://jabber.org/protocol/pubsub#event">>).
|
||||||
|
|
||||||
|
-define(NS_PUBSUB_META_DATA,
|
||||||
|
<<"http://jabber.org/protocol/pubsub#meta-data">>).
|
||||||
|
|
||||||
|
-define(NS_PUBSUB_OWNER,
|
||||||
|
<<"http://jabber.org/protocol/pubsub#owner">>).
|
||||||
|
|
||||||
|
-define(NS_PUBSUB_NMI,
|
||||||
|
<<"http://jabber.org/protocol/pubsub#node-meta-info">>).
|
||||||
|
|
||||||
|
-define(NS_PUBSUB_ERRORS,
|
||||||
|
<<"http://jabber.org/protocol/pubsub#errors">>).
|
||||||
|
|
||||||
|
-define(NS_PUBSUB_NODE_CONFIG,
|
||||||
|
<<"http://jabber.org/protocol/pubsub#node_config">>).
|
||||||
|
|
||||||
|
-define(NS_PUBSUB_SUB_OPTIONS,
|
||||||
|
<<"http://jabber.org/protocol/pubsub#subscribe_options">>).
|
||||||
|
|
||||||
|
-define(NS_PUBSUB_SUBSCRIBE_OPTIONS,
|
||||||
|
<<"http://jabber.org/protocol/pubsub#subscribe_options">>).
|
||||||
|
|
||||||
|
-define(NS_PUBSUB_PUBLISH_OPTIONS,
|
||||||
|
<<"http://jabber.org/protocol/pubsub#publish_options">>).
|
||||||
|
|
||||||
|
-define(NS_PUBSUB_SUB_AUTH,
|
||||||
|
<<"http://jabber.org/protocol/pubsub#subscribe_authorization">>).
|
||||||
|
|
||||||
|
-define(NS_PUBSUB_GET_PENDING,
|
||||||
|
<<"http://jabber.org/protocol/pubsub#get-pending">>).
|
||||||
|
|
||||||
|
-define(NS_COMMANDS,
|
||||||
|
<<"http://jabber.org/protocol/commands">>).
|
||||||
|
|
||||||
|
-define(NS_BYTESTREAMS,
|
||||||
|
<<"http://jabber.org/protocol/bytestreams">>).
|
||||||
|
|
||||||
|
-define(NS_ADMIN,
|
||||||
|
<<"http://jabber.org/protocol/admin">>).
|
||||||
|
-define(NS_ADMIN_ANNOUNCE,
|
||||||
|
<<"http://jabber.org/protocol/admin#announce">>).
|
||||||
|
-define(NS_ADMIN_ANNOUNCE_ALL,
|
||||||
|
<<"http://jabber.org/protocol/admin#announce-all">>).
|
||||||
|
-define(NS_ADMIN_SET_MOTD,
|
||||||
|
<<"http://jabber.org/protocol/admin#set-motd">>).
|
||||||
|
-define(NS_ADMIN_EDIT_MOTD,
|
||||||
|
<<"http://jabber.org/protocol/admin#edit-motd">>).
|
||||||
|
-define(NS_ADMIN_DELETE_MOTD,
|
||||||
|
<<"http://jabber.org/protocol/admin#delete-motd">>).
|
||||||
|
-define(NS_ADMIN_ANNOUNCE_ALLHOSTS,
|
||||||
|
<<"http://jabber.org/protocol/admin#announce-allhosts">>).
|
||||||
|
-define(NS_ADMIN_ANNOUNCE_ALL_ALLHOSTS,
|
||||||
|
<<"http://jabber.org/protocol/admin#announce-all-allhosts">>).
|
||||||
|
-define(NS_ADMIN_SET_MOTD_ALLHOSTS,
|
||||||
|
<<"http://jabber.org/protocol/admin#set-motd-allhosts">>).
|
||||||
|
-define(NS_ADMIN_EDIT_MOTD_ALLHOSTS,
|
||||||
|
<<"http://jabber.org/protocol/admin#edit-motd-allhosts">>).
|
||||||
|
-define(NS_ADMIN_DELETE_MOTD_ALLHOSTS,
|
||||||
|
<<"http://jabber.org/protocol/admin#delete-motd-allhosts">>).
|
||||||
|
|
||||||
|
-define(NS_SERVERINFO,
|
||||||
|
<<"http://jabber.org/network/serverinfo">>).
|
||||||
|
|
||||||
|
-define(NS_RSM, <<"http://jabber.org/protocol/rsm">>).
|
||||||
|
|
||||||
|
-define(NS_EJABBERD_CONFIG, <<"ejabberd:config">>).
|
||||||
|
|
||||||
|
-define(NS_STREAM,
|
||||||
|
<<"http://etherx.jabber.org/streams">>).
|
||||||
|
|
||||||
|
-define(NS_STANZAS,
|
||||||
|
<<"urn:ietf:params:xml:ns:xmpp-stanzas">>).
|
||||||
|
|
||||||
|
-define(NS_STREAMS,
|
||||||
|
<<"urn:ietf:params:xml:ns:xmpp-streams">>).
|
||||||
|
|
||||||
|
-define(NS_TLS, <<"urn:ietf:params:xml:ns:xmpp-tls">>).
|
||||||
|
|
||||||
|
-define(NS_SASL,
|
||||||
|
<<"urn:ietf:params:xml:ns:xmpp-sasl">>).
|
||||||
|
|
||||||
|
-define(NS_SESSION,
|
||||||
|
<<"urn:ietf:params:xml:ns:xmpp-session">>).
|
||||||
|
|
||||||
|
-define(NS_BIND,
|
||||||
|
<<"urn:ietf:params:xml:ns:xmpp-bind">>).
|
||||||
|
|
||||||
|
-define(NS_FEATURE_IQAUTH,
|
||||||
|
<<"http://jabber.org/features/iq-auth">>).
|
||||||
|
|
||||||
|
-define(NS_FEATURE_IQREGISTER,
|
||||||
|
<<"http://jabber.org/features/iq-register">>).
|
||||||
|
|
||||||
|
-define(NS_FEATURE_COMPRESS,
|
||||||
|
<<"http://jabber.org/features/compress">>).
|
||||||
|
|
||||||
|
-define(NS_FEATURE_MSGOFFLINE, <<"msgoffline">>).
|
||||||
|
|
||||||
|
-define(NS_COMPRESS,
|
||||||
|
<<"http://jabber.org/protocol/compress">>).
|
||||||
|
|
||||||
|
-define(NS_CAPS, <<"http://jabber.org/protocol/caps">>).
|
||||||
|
|
||||||
|
-define(NS_SHIM, <<"http://jabber.org/protocol/shim">>).
|
||||||
|
|
||||||
|
-define(NS_ADDRESS,
|
||||||
|
<<"http://jabber.org/protocol/address">>).
|
||||||
|
|
||||||
|
-define(NS_OOB, <<"jabber:x:oob">>).
|
||||||
|
|
||||||
|
-define(NS_CAPTCHA, <<"urn:xmpp:captcha">>).
|
||||||
|
|
||||||
|
-define(NS_MEDIA, <<"urn:xmpp:media-element">>).
|
||||||
|
|
||||||
|
-define(NS_BOB, <<"urn:xmpp:bob">>).
|
||||||
|
|
||||||
% TODO: remove "code" attribute (currently it used for backward-compatibility)
|
|
||||||
-define(STANZA_ERROR(Code, Type, Condition),
|
-define(STANZA_ERROR(Code, Type, Condition),
|
||||||
{xmlelement, "error",
|
#xmlel{name = <<"error">>,
|
||||||
[{"code", Code}, {"type", Type}],
|
attrs = [{<<"code">>, Code}, {<<"type">>, Type}],
|
||||||
[{xmlelement, Condition, [{"xmlns", ?NS_STANZAS}], []}]}).
|
children =
|
||||||
|
[#xmlel{name = Condition,
|
||||||
|
attrs = [{<<"xmlns">>, ?NS_STANZAS}],
|
||||||
|
children = []}]}).
|
||||||
|
|
||||||
-define(ERR_BAD_FORMAT,
|
-define(ERR_BAD_FORMAT,
|
||||||
?STANZA_ERROR("406", "modify", "bad-format")).
|
?STANZA_ERROR(<<"406">>, <<"modify">>,
|
||||||
|
<<"bad-format">>)).
|
||||||
|
|
||||||
-define(ERR_BAD_REQUEST,
|
-define(ERR_BAD_REQUEST,
|
||||||
?STANZA_ERROR("400", "modify", "bad-request")).
|
?STANZA_ERROR(<<"400">>, <<"modify">>,
|
||||||
|
<<"bad-request">>)).
|
||||||
|
|
||||||
-define(ERR_CONFLICT,
|
-define(ERR_CONFLICT,
|
||||||
?STANZA_ERROR("409", "cancel", "conflict")).
|
?STANZA_ERROR(<<"409">>, <<"cancel">>, <<"conflict">>)).
|
||||||
|
|
||||||
-define(ERR_FEATURE_NOT_IMPLEMENTED,
|
-define(ERR_FEATURE_NOT_IMPLEMENTED,
|
||||||
?STANZA_ERROR("501", "cancel", "feature-not-implemented")).
|
?STANZA_ERROR(<<"501">>, <<"cancel">>,
|
||||||
|
<<"feature-not-implemented">>)).
|
||||||
|
|
||||||
-define(ERR_FORBIDDEN,
|
-define(ERR_FORBIDDEN,
|
||||||
?STANZA_ERROR("403", "auth", "forbidden")).
|
?STANZA_ERROR(<<"403">>, <<"auth">>, <<"forbidden">>)).
|
||||||
|
|
||||||
-define(ERR_GONE,
|
-define(ERR_GONE,
|
||||||
?STANZA_ERROR("302", "modify", "gone")).
|
?STANZA_ERROR(<<"302">>, <<"modify">>, <<"gone">>)).
|
||||||
|
|
||||||
-define(ERR_INTERNAL_SERVER_ERROR,
|
-define(ERR_INTERNAL_SERVER_ERROR,
|
||||||
?STANZA_ERROR("500", "wait", "internal-server-error")).
|
?STANZA_ERROR(<<"500">>, <<"wait">>,
|
||||||
|
<<"internal-server-error">>)).
|
||||||
|
|
||||||
-define(ERR_ITEM_NOT_FOUND,
|
-define(ERR_ITEM_NOT_FOUND,
|
||||||
?STANZA_ERROR("404", "cancel", "item-not-found")).
|
?STANZA_ERROR(<<"404">>, <<"cancel">>,
|
||||||
|
<<"item-not-found">>)).
|
||||||
|
|
||||||
-define(ERR_JID_MALFORMED,
|
-define(ERR_JID_MALFORMED,
|
||||||
?STANZA_ERROR("400", "modify", "jid-malformed")).
|
?STANZA_ERROR(<<"400">>, <<"modify">>,
|
||||||
|
<<"jid-malformed">>)).
|
||||||
|
|
||||||
-define(ERR_NOT_ACCEPTABLE,
|
-define(ERR_NOT_ACCEPTABLE,
|
||||||
?STANZA_ERROR("406", "modify", "not-acceptable")).
|
?STANZA_ERROR(<<"406">>, <<"modify">>,
|
||||||
|
<<"not-acceptable">>)).
|
||||||
|
|
||||||
-define(ERR_NOT_ALLOWED,
|
-define(ERR_NOT_ALLOWED,
|
||||||
?STANZA_ERROR("405", "cancel", "not-allowed")).
|
?STANZA_ERROR(<<"405">>, <<"cancel">>,
|
||||||
|
<<"not-allowed">>)).
|
||||||
|
|
||||||
-define(ERR_NOT_AUTHORIZED,
|
-define(ERR_NOT_AUTHORIZED,
|
||||||
?STANZA_ERROR("401", "auth", "not-authorized")).
|
?STANZA_ERROR(<<"401">>, <<"auth">>,
|
||||||
|
<<"not-authorized">>)).
|
||||||
|
|
||||||
-define(ERR_PAYMENT_REQUIRED,
|
-define(ERR_PAYMENT_REQUIRED,
|
||||||
?STANZA_ERROR("402", "auth", "payment-required")).
|
?STANZA_ERROR(<<"402">>, <<"auth">>,
|
||||||
|
<<"payment-required">>)).
|
||||||
|
|
||||||
-define(ERR_RECIPIENT_UNAVAILABLE,
|
-define(ERR_RECIPIENT_UNAVAILABLE,
|
||||||
?STANZA_ERROR("404", "wait", "recipient-unavailable")).
|
?STANZA_ERROR(<<"404">>, <<"wait">>,
|
||||||
|
<<"recipient-unavailable">>)).
|
||||||
|
|
||||||
-define(ERR_REDIRECT,
|
-define(ERR_REDIRECT,
|
||||||
?STANZA_ERROR("302", "modify", "redirect")).
|
?STANZA_ERROR(<<"302">>, <<"modify">>, <<"redirect">>)).
|
||||||
|
|
||||||
-define(ERR_REGISTRATION_REQUIRED,
|
-define(ERR_REGISTRATION_REQUIRED,
|
||||||
?STANZA_ERROR("407", "auth", "registration-required")).
|
?STANZA_ERROR(<<"407">>, <<"auth">>,
|
||||||
|
<<"registration-required">>)).
|
||||||
|
|
||||||
-define(ERR_REMOTE_SERVER_NOT_FOUND,
|
-define(ERR_REMOTE_SERVER_NOT_FOUND,
|
||||||
?STANZA_ERROR("404", "cancel", "remote-server-not-found")).
|
?STANZA_ERROR(<<"404">>, <<"cancel">>,
|
||||||
|
<<"remote-server-not-found">>)).
|
||||||
|
|
||||||
-define(ERR_REMOTE_SERVER_TIMEOUT,
|
-define(ERR_REMOTE_SERVER_TIMEOUT,
|
||||||
?STANZA_ERROR("504", "wait", "remote-server-timeout")).
|
?STANZA_ERROR(<<"504">>, <<"wait">>,
|
||||||
|
<<"remote-server-timeout">>)).
|
||||||
|
|
||||||
-define(ERR_RESOURCE_CONSTRAINT,
|
-define(ERR_RESOURCE_CONSTRAINT,
|
||||||
?STANZA_ERROR("500", "wait", "resource-constraint")).
|
?STANZA_ERROR(<<"500">>, <<"wait">>,
|
||||||
|
<<"resource-constraint">>)).
|
||||||
|
|
||||||
-define(ERR_SERVICE_UNAVAILABLE,
|
-define(ERR_SERVICE_UNAVAILABLE,
|
||||||
?STANZA_ERROR("503", "cancel", "service-unavailable")).
|
?STANZA_ERROR(<<"503">>, <<"cancel">>,
|
||||||
|
<<"service-unavailable">>)).
|
||||||
|
|
||||||
-define(ERR_SUBSCRIPTION_REQUIRED,
|
-define(ERR_SUBSCRIPTION_REQUIRED,
|
||||||
?STANZA_ERROR("407", "auth", "subscription-required")).
|
?STANZA_ERROR(<<"407">>, <<"auth">>,
|
||||||
|
<<"subscription-required">>)).
|
||||||
|
|
||||||
-define(ERR_UNEXPECTED_REQUEST,
|
-define(ERR_UNEXPECTED_REQUEST,
|
||||||
?STANZA_ERROR("400", "wait", "unexpected-request")).
|
?STANZA_ERROR(<<"400">>, <<"wait">>,
|
||||||
|
<<"unexpected-request">>)).
|
||||||
|
|
||||||
-define(ERR_UNEXPECTED_REQUEST_CANCEL,
|
-define(ERR_UNEXPECTED_REQUEST_CANCEL,
|
||||||
?STANZA_ERROR("401", "cancel", "unexpected-request")).
|
?STANZA_ERROR(<<"401">>, <<"cancel">>,
|
||||||
|
<<"unexpected-request">>)).
|
||||||
|
|
||||||
%-define(ERR_,
|
%-define(ERR_,
|
||||||
% ?STANZA_ERROR("", "", "")).
|
% ?STANZA_ERROR("", "", "")).
|
||||||
|
|
||||||
-define(STANZA_ERRORT(Code, Type, Condition, Lang, Text),
|
-define(STANZA_ERRORT(Code, Type, Condition, Lang,
|
||||||
{xmlelement, "error",
|
Text),
|
||||||
[{"code", Code}, {"type", Type}],
|
#xmlel{name = <<"error">>,
|
||||||
[{xmlelement, Condition, [{"xmlns", ?NS_STANZAS}], []},
|
attrs = [{<<"code">>, Code}, {<<"type">>, Type}],
|
||||||
{xmlelement, "text", [{"xmlns", ?NS_STANZAS}],
|
children =
|
||||||
[{xmlcdata, translate:translate(Lang, Text)}]}]}).
|
[#xmlel{name = Condition,
|
||||||
|
attrs = [{<<"xmlns">>, ?NS_STANZAS}], children = []},
|
||||||
|
#xmlel{name = <<"text">>,
|
||||||
|
attrs = [{<<"xmlns">>, ?NS_STANZAS}],
|
||||||
|
children =
|
||||||
|
[{xmlcdata,
|
||||||
|
translate:translate(Lang, Text)}]}]}).
|
||||||
|
|
||||||
-define(ERRT_BAD_FORMAT(Lang, Text),
|
-define(ERRT_BAD_FORMAT(Lang, Text),
|
||||||
?STANZA_ERRORT("406", "modify", "bad-format", Lang, Text)).
|
?STANZA_ERRORT(<<"406">>, <<"modify">>,
|
||||||
|
<<"bad-format">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_BAD_REQUEST(Lang, Text),
|
-define(ERRT_BAD_REQUEST(Lang, Text),
|
||||||
?STANZA_ERRORT("400", "modify", "bad-request", Lang, Text)).
|
?STANZA_ERRORT(<<"400">>, <<"modify">>,
|
||||||
|
<<"bad-request">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_CONFLICT(Lang, Text),
|
-define(ERRT_CONFLICT(Lang, Text),
|
||||||
?STANZA_ERRORT("409", "cancel", "conflict", Lang, Text)).
|
?STANZA_ERRORT(<<"409">>, <<"cancel">>, <<"conflict">>,
|
||||||
|
Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_FEATURE_NOT_IMPLEMENTED(Lang, Text),
|
-define(ERRT_FEATURE_NOT_IMPLEMENTED(Lang, Text),
|
||||||
?STANZA_ERRORT("501", "cancel", "feature-not-implemented", Lang, Text)).
|
?STANZA_ERRORT(<<"501">>, <<"cancel">>,
|
||||||
|
<<"feature-not-implemented">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_FORBIDDEN(Lang, Text),
|
-define(ERRT_FORBIDDEN(Lang, Text),
|
||||||
?STANZA_ERRORT("403", "auth", "forbidden", Lang, Text)).
|
?STANZA_ERRORT(<<"403">>, <<"auth">>, <<"forbidden">>,
|
||||||
|
Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_GONE(Lang, Text),
|
-define(ERRT_GONE(Lang, Text),
|
||||||
?STANZA_ERRORT("302", "modify", "gone", Lang, Text)).
|
?STANZA_ERRORT(<<"302">>, <<"modify">>, <<"gone">>,
|
||||||
|
Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_INTERNAL_SERVER_ERROR(Lang, Text),
|
-define(ERRT_INTERNAL_SERVER_ERROR(Lang, Text),
|
||||||
?STANZA_ERRORT("500", "wait", "internal-server-error", Lang, Text)).
|
?STANZA_ERRORT(<<"500">>, <<"wait">>,
|
||||||
|
<<"internal-server-error">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_ITEM_NOT_FOUND(Lang, Text),
|
-define(ERRT_ITEM_NOT_FOUND(Lang, Text),
|
||||||
?STANZA_ERRORT("404", "cancel", "item-not-found", Lang, Text)).
|
?STANZA_ERRORT(<<"404">>, <<"cancel">>,
|
||||||
|
<<"item-not-found">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_JID_MALFORMED(Lang, Text),
|
-define(ERRT_JID_MALFORMED(Lang, Text),
|
||||||
?STANZA_ERRORT("400", "modify", "jid-malformed", Lang, Text)).
|
?STANZA_ERRORT(<<"400">>, <<"modify">>,
|
||||||
|
<<"jid-malformed">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_NOT_ACCEPTABLE(Lang, Text),
|
-define(ERRT_NOT_ACCEPTABLE(Lang, Text),
|
||||||
?STANZA_ERRORT("406", "modify", "not-acceptable", Lang, Text)).
|
?STANZA_ERRORT(<<"406">>, <<"modify">>,
|
||||||
|
<<"not-acceptable">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_NOT_ALLOWED(Lang, Text),
|
-define(ERRT_NOT_ALLOWED(Lang, Text),
|
||||||
?STANZA_ERRORT("405", "cancel", "not-allowed", Lang, Text)).
|
?STANZA_ERRORT(<<"405">>, <<"cancel">>,
|
||||||
|
<<"not-allowed">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_NOT_AUTHORIZED(Lang, Text),
|
-define(ERRT_NOT_AUTHORIZED(Lang, Text),
|
||||||
?STANZA_ERRORT("401", "auth", "not-authorized", Lang, Text)).
|
?STANZA_ERRORT(<<"401">>, <<"auth">>,
|
||||||
|
<<"not-authorized">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_PAYMENT_REQUIRED(Lang, Text),
|
-define(ERRT_PAYMENT_REQUIRED(Lang, Text),
|
||||||
?STANZA_ERRORT("402", "auth", "payment-required", Lang, Text)).
|
?STANZA_ERRORT(<<"402">>, <<"auth">>,
|
||||||
|
<<"payment-required">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_RECIPIENT_UNAVAILABLE(Lang, Text),
|
-define(ERRT_RECIPIENT_UNAVAILABLE(Lang, Text),
|
||||||
?STANZA_ERRORT("404", "wait", "recipient-unavailable", Lang, Text)).
|
?STANZA_ERRORT(<<"404">>, <<"wait">>,
|
||||||
|
<<"recipient-unavailable">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_REDIRECT(Lang, Text),
|
-define(ERRT_REDIRECT(Lang, Text),
|
||||||
?STANZA_ERRORT("302", "modify", "redirect", Lang, Text)).
|
?STANZA_ERRORT(<<"302">>, <<"modify">>, <<"redirect">>,
|
||||||
|
Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_REGISTRATION_REQUIRED(Lang, Text),
|
-define(ERRT_REGISTRATION_REQUIRED(Lang, Text),
|
||||||
?STANZA_ERRORT("407", "auth", "registration-required", Lang, Text)).
|
?STANZA_ERRORT(<<"407">>, <<"auth">>,
|
||||||
|
<<"registration-required">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_REMOTE_SERVER_NOT_FOUND(Lang, Text),
|
-define(ERRT_REMOTE_SERVER_NOT_FOUND(Lang, Text),
|
||||||
?STANZA_ERRORT("404", "cancel", "remote-server-not-found", Lang, Text)).
|
?STANZA_ERRORT(<<"404">>, <<"cancel">>,
|
||||||
|
<<"remote-server-not-found">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_REMOTE_SERVER_TIMEOUT(Lang, Text),
|
-define(ERRT_REMOTE_SERVER_TIMEOUT(Lang, Text),
|
||||||
?STANZA_ERRORT("504", "wait", "remote-server-timeout", Lang, Text)).
|
?STANZA_ERRORT(<<"504">>, <<"wait">>,
|
||||||
|
<<"remote-server-timeout">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_RESOURCE_CONSTRAINT(Lang, Text),
|
-define(ERRT_RESOURCE_CONSTRAINT(Lang, Text),
|
||||||
?STANZA_ERRORT("500", "wait", "resource-constraint", Lang, Text)).
|
?STANZA_ERRORT(<<"500">>, <<"wait">>,
|
||||||
|
<<"resource-constraint">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_SERVICE_UNAVAILABLE(Lang, Text),
|
-define(ERRT_SERVICE_UNAVAILABLE(Lang, Text),
|
||||||
?STANZA_ERRORT("503", "cancel", "service-unavailable", Lang, Text)).
|
?STANZA_ERRORT(<<"503">>, <<"cancel">>,
|
||||||
|
<<"service-unavailable">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_SUBSCRIPTION_REQUIRED(Lang, Text),
|
-define(ERRT_SUBSCRIPTION_REQUIRED(Lang, Text),
|
||||||
?STANZA_ERRORT("407", "auth", "subscription-required", Lang, Text)).
|
?STANZA_ERRORT(<<"407">>, <<"auth">>,
|
||||||
|
<<"subscription-required">>, Lang, Text)).
|
||||||
|
|
||||||
-define(ERRT_UNEXPECTED_REQUEST(Lang, Text),
|
-define(ERRT_UNEXPECTED_REQUEST(Lang, Text),
|
||||||
?STANZA_ERRORT("400", "wait", "unexpected-request", Lang, Text)).
|
?STANZA_ERRORT(<<"400">>, <<"wait">>,
|
||||||
|
<<"unexpected-request">>, Lang, Text)).
|
||||||
|
|
||||||
% Auth stanza errors
|
|
||||||
-define(ERR_AUTH_NO_RESOURCE_PROVIDED(Lang),
|
-define(ERR_AUTH_NO_RESOURCE_PROVIDED(Lang),
|
||||||
?ERRT_NOT_ACCEPTABLE(Lang, "No resource provided")).
|
?ERRT_NOT_ACCEPTABLE(Lang, <<"No resource provided">>)).
|
||||||
|
|
||||||
-define(ERR_AUTH_BAD_RESOURCE_FORMAT(Lang),
|
-define(ERR_AUTH_BAD_RESOURCE_FORMAT(Lang),
|
||||||
?ERRT_NOT_ACCEPTABLE(Lang, "Illegal resource format")).
|
?ERRT_NOT_ACCEPTABLE(Lang,
|
||||||
|
<<"Illegal resource format">>)).
|
||||||
|
|
||||||
-define(ERR_AUTH_RESOURCE_CONFLICT(Lang),
|
-define(ERR_AUTH_RESOURCE_CONFLICT(Lang),
|
||||||
?ERRT_CONFLICT(Lang, "Resource conflict")).
|
?ERRT_CONFLICT(Lang, <<"Resource conflict">>)).
|
||||||
|
|
||||||
|
-define(STREAM_ERROR(Condition, Cdata),
|
||||||
-define(STREAM_ERROR(Condition),
|
#xmlel{name = <<"stream:error">>, attrs = [],
|
||||||
{xmlelement, "stream:error",
|
children =
|
||||||
[],
|
[#xmlel{name = Condition,
|
||||||
[{xmlelement, Condition, [{"xmlns", ?NS_STREAMS}], []}]}).
|
attrs = [{<<"xmlns">>, ?NS_STREAMS}],
|
||||||
|
children = [{xmlcdata, Cdata}]}]}).
|
||||||
|
|
||||||
-define(SERR_BAD_FORMAT,
|
-define(SERR_BAD_FORMAT,
|
||||||
?STREAM_ERROR("bad-format")).
|
?STREAM_ERROR(<<"bad-format">>, <<"">>)).
|
||||||
-define(SERR_BAD_NAMESPACE_PREFIX,
|
|
||||||
?STREAM_ERROR("bad-namespace-prefix")).
|
|
||||||
-define(SERR_CONFLICT,
|
|
||||||
?STREAM_ERROR("conflict")).
|
|
||||||
-define(SERR_CONNECTION_TIMEOUT,
|
|
||||||
?STREAM_ERROR("connection-timeout")).
|
|
||||||
-define(SERR_HOST_GONE,
|
|
||||||
?STREAM_ERROR("host-gone")).
|
|
||||||
-define(SERR_HOST_UNKNOWN,
|
|
||||||
?STREAM_ERROR("host-unknown")).
|
|
||||||
-define(SERR_IMPROPER_ADDRESSING,
|
|
||||||
?STREAM_ERROR("improper-addressing")).
|
|
||||||
-define(SERR_INTERNAL_SERVER_ERROR,
|
|
||||||
?STREAM_ERROR("internal-server-error")).
|
|
||||||
-define(SERR_INVALID_FROM,
|
|
||||||
?STREAM_ERROR("invalid-from")).
|
|
||||||
-define(SERR_INVALID_ID,
|
|
||||||
?STREAM_ERROR("invalid-id")).
|
|
||||||
-define(SERR_INVALID_NAMESPACE,
|
|
||||||
?STREAM_ERROR("invalid-namespace")).
|
|
||||||
-define(SERR_INVALID_XML,
|
|
||||||
?STREAM_ERROR("invalid-xml")).
|
|
||||||
-define(SERR_NOT_AUTHORIZED,
|
|
||||||
?STREAM_ERROR("not-authorized")).
|
|
||||||
-define(SERR_POLICY_VIOLATION,
|
|
||||||
?STREAM_ERROR("policy-violation")).
|
|
||||||
-define(SERR_REMOTE_CONNECTION_FAILED,
|
|
||||||
?STREAM_ERROR("remote-connection-failed")).
|
|
||||||
-define(SERR_RESOURSE_CONSTRAINT,
|
|
||||||
?STREAM_ERROR("resource-constraint")).
|
|
||||||
-define(SERR_RESTRICTED_XML,
|
|
||||||
?STREAM_ERROR("restricted-xml")).
|
|
||||||
% TODO: include hostname or IP
|
|
||||||
-define(SERR_SEE_OTHER_HOST,
|
|
||||||
?STREAM_ERROR("see-other-host")).
|
|
||||||
-define(SERR_SYSTEM_SHUTDOWN,
|
|
||||||
?STREAM_ERROR("system-shutdown")).
|
|
||||||
-define(SERR_UNSUPPORTED_ENCODING,
|
|
||||||
?STREAM_ERROR("unsupported-encoding")).
|
|
||||||
-define(SERR_UNSUPPORTED_STANZA_TYPE,
|
|
||||||
?STREAM_ERROR("unsupported-stanza-type")).
|
|
||||||
-define(SERR_UNSUPPORTED_VERSION,
|
|
||||||
?STREAM_ERROR("unsupported-version")).
|
|
||||||
-define(SERR_XML_NOT_WELL_FORMED,
|
|
||||||
?STREAM_ERROR("xml-not-well-formed")).
|
|
||||||
%-define(SERR_,
|
|
||||||
% ?STREAM_ERROR("")).
|
|
||||||
|
|
||||||
-define(STREAM_ERRORT(Condition, Lang, Text),
|
-define(SERR_BAD_NAMESPACE_PREFIX,
|
||||||
{xmlelement, "stream:error",
|
?STREAM_ERROR(<<"bad-namespace-prefix">>, <<"">>)).
|
||||||
[],
|
|
||||||
[{xmlelement, Condition, [{"xmlns", ?NS_STREAMS}], []},
|
-define(SERR_CONFLICT,
|
||||||
{xmlelement, "text", [{"xml:lang", Lang}, {"xmlns", ?NS_STREAMS}],
|
?STREAM_ERROR(<<"conflict">>, <<"">>)).
|
||||||
[{xmlcdata, translate:translate(Lang, Text)}]}]}).
|
|
||||||
|
-define(SERR_CONNECTION_TIMEOUT,
|
||||||
|
?STREAM_ERROR(<<"connection-timeout">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_HOST_GONE,
|
||||||
|
?STREAM_ERROR(<<"host-gone">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_HOST_UNKNOWN,
|
||||||
|
?STREAM_ERROR(<<"host-unknown">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_IMPROPER_ADDRESSING,
|
||||||
|
?STREAM_ERROR(<<"improper-addressing">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_INTERNAL_SERVER_ERROR,
|
||||||
|
?STREAM_ERROR(<<"internal-server-error">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_INVALID_FROM,
|
||||||
|
?STREAM_ERROR(<<"invalid-from">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_INVALID_ID,
|
||||||
|
?STREAM_ERROR(<<"invalid-id">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_INVALID_NAMESPACE,
|
||||||
|
?STREAM_ERROR(<<"invalid-namespace">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_INVALID_XML,
|
||||||
|
?STREAM_ERROR(<<"invalid-xml">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_NOT_AUTHORIZED,
|
||||||
|
?STREAM_ERROR(<<"not-authorized">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_POLICY_VIOLATION,
|
||||||
|
?STREAM_ERROR(<<"policy-violation">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_REMOTE_CONNECTION_FAILED,
|
||||||
|
?STREAM_ERROR(<<"remote-connection-failed">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_RESOURSE_CONSTRAINT,
|
||||||
|
?STREAM_ERROR(<<"resource-constraint">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_RESTRICTED_XML,
|
||||||
|
?STREAM_ERROR(<<"restricted-xml">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_SEE_OTHER_HOST(Host),
|
||||||
|
?STREAM_ERROR(<<"see-other-host">>, Host)).
|
||||||
|
|
||||||
|
-define(SERR_SYSTEM_SHUTDOWN,
|
||||||
|
?STREAM_ERROR(<<"system-shutdown">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_UNSUPPORTED_ENCODING,
|
||||||
|
?STREAM_ERROR(<<"unsupported-encoding">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_UNSUPPORTED_STANZA_TYPE,
|
||||||
|
?STREAM_ERROR(<<"unsupported-stanza-type">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_UNSUPPORTED_VERSION,
|
||||||
|
?STREAM_ERROR(<<"unsupported-version">>, <<"">>)).
|
||||||
|
|
||||||
|
-define(SERR_XML_NOT_WELL_FORMED,
|
||||||
|
?STREAM_ERROR(<<"xml-not-well-formed">>, <<"">>)).
|
||||||
|
|
||||||
|
%-define(SERR_,
|
||||||
|
% ?STREAM_ERROR("", "")).
|
||||||
|
|
||||||
|
-define(STREAM_ERRORT(Condition, Cdata, Lang, Text),
|
||||||
|
#xmlel{name = <<"stream:error">>, attrs = [],
|
||||||
|
children =
|
||||||
|
[#xmlel{name = Condition,
|
||||||
|
attrs = [{<<"xmlns">>, ?NS_STREAMS}],
|
||||||
|
children = [{xmlcdata, Cdata}]},
|
||||||
|
#xmlel{name = <<"text">>,
|
||||||
|
attrs =
|
||||||
|
[{<<"xml:lang">>, Lang},
|
||||||
|
{<<"xmlns">>, ?NS_STREAMS}],
|
||||||
|
children =
|
||||||
|
[{xmlcdata,
|
||||||
|
translate:translate(Lang, Text)}]}]}).
|
||||||
|
|
||||||
-define(SERRT_BAD_FORMAT(Lang, Text),
|
-define(SERRT_BAD_FORMAT(Lang, Text),
|
||||||
?STREAM_ERRORT("bad-format", Lang, Text)).
|
?STREAM_ERRORT(<<"bad-format">>, <<"">>, Lang, Text)).
|
||||||
|
|
||||||
-define(SERRT_BAD_NAMESPACE_PREFIX(Lang, Text),
|
-define(SERRT_BAD_NAMESPACE_PREFIX(Lang, Text),
|
||||||
?STREAM_ERRORT("bad-namespace-prefix", Lang, Text)).
|
?STREAM_ERRORT(<<"bad-namespace-prefix">>, <<"">>, Lang,
|
||||||
|
Text)).
|
||||||
|
|
||||||
-define(SERRT_CONFLICT(Lang, Text),
|
-define(SERRT_CONFLICT(Lang, Text),
|
||||||
?STREAM_ERRORT("conflict", Lang, Text)).
|
?STREAM_ERRORT(<<"conflict">>, <<"">>, Lang, Text)).
|
||||||
|
|
||||||
-define(SERRT_CONNECTION_TIMEOUT(Lang, Text),
|
-define(SERRT_CONNECTION_TIMEOUT(Lang, Text),
|
||||||
?STREAM_ERRORT("connection-timeout", Lang, Text)).
|
?STREAM_ERRORT(<<"connection-timeout">>, <<"">>, Lang,
|
||||||
|
Text)).
|
||||||
|
|
||||||
-define(SERRT_HOST_GONE(Lang, Text),
|
-define(SERRT_HOST_GONE(Lang, Text),
|
||||||
?STREAM_ERRORT("host-gone", Lang, Text)).
|
?STREAM_ERRORT(<<"host-gone">>, <<"">>, Lang, Text)).
|
||||||
|
|
||||||
-define(SERRT_HOST_UNKNOWN(Lang, Text),
|
-define(SERRT_HOST_UNKNOWN(Lang, Text),
|
||||||
?STREAM_ERRORT("host-unknown", Lang, Text)).
|
?STREAM_ERRORT(<<"host-unknown">>, <<"">>, Lang, Text)).
|
||||||
|
|
||||||
-define(SERRT_IMPROPER_ADDRESSING(Lang, Text),
|
-define(SERRT_IMPROPER_ADDRESSING(Lang, Text),
|
||||||
?STREAM_ERRORT("improper-addressing", Lang, Text)).
|
?STREAM_ERRORT(<<"improper-addressing">>, <<"">>, Lang,
|
||||||
|
Text)).
|
||||||
|
|
||||||
-define(SERRT_INTERNAL_SERVER_ERROR(Lang, Text),
|
-define(SERRT_INTERNAL_SERVER_ERROR(Lang, Text),
|
||||||
?STREAM_ERRORT("internal-server-error", Lang, Text)).
|
?STREAM_ERRORT(<<"internal-server-error">>, <<"">>,
|
||||||
|
Lang, Text)).
|
||||||
|
|
||||||
-define(SERRT_INVALID_FROM(Lang, Text),
|
-define(SERRT_INVALID_FROM(Lang, Text),
|
||||||
?STREAM_ERRORT("invalid-from", Lang, Text)).
|
?STREAM_ERRORT(<<"invalid-from">>, <<"">>, Lang, Text)).
|
||||||
|
|
||||||
-define(SERRT_INVALID_ID(Lang, Text),
|
-define(SERRT_INVALID_ID(Lang, Text),
|
||||||
?STREAM_ERRORT("invalid-id", Lang, Text)).
|
?STREAM_ERRORT(<<"invalid-id">>, <<"">>, Lang, Text)).
|
||||||
|
|
||||||
-define(SERRT_INVALID_NAMESPACE(Lang, Text),
|
-define(SERRT_INVALID_NAMESPACE(Lang, Text),
|
||||||
?STREAM_ERRORT("invalid-namespace", Lang, Text)).
|
?STREAM_ERRORT(<<"invalid-namespace">>, <<"">>, Lang,
|
||||||
|
Text)).
|
||||||
|
|
||||||
-define(SERRT_INVALID_XML(Lang, Text),
|
-define(SERRT_INVALID_XML(Lang, Text),
|
||||||
?STREAM_ERRORT("invalid-xml", Lang, Text)).
|
?STREAM_ERRORT(<<"invalid-xml">>, <<"">>, Lang, Text)).
|
||||||
|
|
||||||
-define(SERRT_NOT_AUTHORIZED(Lang, Text),
|
-define(SERRT_NOT_AUTHORIZED(Lang, Text),
|
||||||
?STREAM_ERRORT("not-authorized", Lang, Text)).
|
?STREAM_ERRORT(<<"not-authorized">>, <<"">>, Lang,
|
||||||
|
Text)).
|
||||||
|
|
||||||
-define(SERRT_POLICY_VIOLATION(Lang, Text),
|
-define(SERRT_POLICY_VIOLATION(Lang, Text),
|
||||||
?STREAM_ERRORT("policy-violation", Lang, Text)).
|
?STREAM_ERRORT(<<"policy-violation">>, <<"">>, Lang,
|
||||||
|
Text)).
|
||||||
|
|
||||||
-define(SERRT_REMOTE_CONNECTION_FAILED(Lang, Text),
|
-define(SERRT_REMOTE_CONNECTION_FAILED(Lang, Text),
|
||||||
?STREAM_ERRORT("remote-connection-failed", Lang, Text)).
|
?STREAM_ERRORT(<<"remote-connection-failed">>, <<"">>,
|
||||||
|
Lang, Text)).
|
||||||
|
|
||||||
-define(SERRT_RESOURSE_CONSTRAINT(Lang, Text),
|
-define(SERRT_RESOURSE_CONSTRAINT(Lang, Text),
|
||||||
?STREAM_ERRORT("resource-constraint", Lang, Text)).
|
?STREAM_ERRORT(<<"resource-constraint">>, <<"">>, Lang,
|
||||||
|
Text)).
|
||||||
|
|
||||||
-define(SERRT_RESTRICTED_XML(Lang, Text),
|
-define(SERRT_RESTRICTED_XML(Lang, Text),
|
||||||
?STREAM_ERRORT("restricted-xml", Lang, Text)).
|
?STREAM_ERRORT(<<"restricted-xml">>, <<"">>, Lang,
|
||||||
% TODO: include hostname or IP
|
Text)).
|
||||||
-define(SERRT_SEE_OTHER_HOST(Lang, Text),
|
|
||||||
?STREAM_ERRORT("see-other-host", Lang, Text)).
|
-define(SERRT_SEE_OTHER_HOST(Host, Lang, Text),
|
||||||
|
?STREAM_ERRORT(<<"see-other-host">>, Host, Lang, Text)).
|
||||||
|
|
||||||
-define(SERRT_SYSTEM_SHUTDOWN(Lang, Text),
|
-define(SERRT_SYSTEM_SHUTDOWN(Lang, Text),
|
||||||
?STREAM_ERRORT("system-shutdown", Lang, Text)).
|
?STREAM_ERRORT(<<"system-shutdown">>, <<"">>, Lang,
|
||||||
|
Text)).
|
||||||
|
|
||||||
-define(SERRT_UNSUPPORTED_ENCODING(Lang, Text),
|
-define(SERRT_UNSUPPORTED_ENCODING(Lang, Text),
|
||||||
?STREAM_ERRORT("unsupported-encoding", Lang, Text)).
|
?STREAM_ERRORT(<<"unsupported-encoding">>, <<"">>, Lang,
|
||||||
|
Text)).
|
||||||
|
|
||||||
-define(SERRT_UNSUPPORTED_STANZA_TYPE(Lang, Text),
|
-define(SERRT_UNSUPPORTED_STANZA_TYPE(Lang, Text),
|
||||||
?STREAM_ERRORT("unsupported-stanza-type", Lang, Text)).
|
?STREAM_ERRORT(<<"unsupported-stanza-type">>, <<"">>,
|
||||||
|
Lang, Text)).
|
||||||
|
|
||||||
-define(SERRT_UNSUPPORTED_VERSION(Lang, Text),
|
-define(SERRT_UNSUPPORTED_VERSION(Lang, Text),
|
||||||
?STREAM_ERRORT("unsupported-version", Lang, Text)).
|
?STREAM_ERRORT(<<"unsupported-version">>, <<"">>, Lang,
|
||||||
|
Text)).
|
||||||
|
|
||||||
-define(SERRT_XML_NOT_WELL_FORMED(Lang, Text),
|
-define(SERRT_XML_NOT_WELL_FORMED(Lang, Text),
|
||||||
?STREAM_ERRORT("xml-not-well-formed", Lang, Text)).
|
?STREAM_ERRORT(<<"xml-not-well-formed">>, <<"">>, Lang,
|
||||||
%-define(SERRT_(Lang, Text),
|
Text)).
|
||||||
% ?STREAM_ERRORT("", Lang, Text)).
|
|
||||||
|
|
||||||
|
-record(jid, {user = <<"">> :: binary(),
|
||||||
|
server = <<"">> :: binary(),
|
||||||
|
resource = <<"">> :: binary(),
|
||||||
|
luser = <<"">> :: binary(),
|
||||||
|
lserver = <<"">> :: binary(),
|
||||||
|
lresource = <<"">> :: binary()}).
|
||||||
|
|
||||||
-record(jid, {user, server, resource,
|
-type(jid() :: #jid{}).
|
||||||
luser, lserver, lresource}).
|
|
||||||
|
|
||||||
-record(iq, {id = "",
|
-type(ljid() :: {binary(), binary(), binary()}).
|
||||||
type,
|
|
||||||
xmlns = "",
|
|
||||||
lang = "",
|
|
||||||
sub_el}).
|
|
||||||
|
|
||||||
-record(rsm_in, {max, direction, id, index}).
|
-record(xmlel,
|
||||||
-record(rsm_out, {count, index, first, last}).
|
{
|
||||||
|
name = <<"">> :: binary(),
|
||||||
|
attrs = [] :: [attr()],
|
||||||
|
children = [] :: [xmlel() | cdata()]
|
||||||
|
}).
|
||||||
|
|
||||||
|
-type(cdata() :: {xmlcdata, CData::binary()}).
|
||||||
|
|
||||||
|
-type(attr() :: {Name::binary(), Value::binary()}).
|
||||||
|
|
||||||
|
-type(xmlel() :: #xmlel{}).
|
||||||
|
|
||||||
|
-record(iq, {id = <<"">> :: binary(),
|
||||||
|
type = get :: get | set | result | error,
|
||||||
|
xmlns = <<"">> :: binary(),
|
||||||
|
lang = <<"">> :: binary(),
|
||||||
|
sub_el = #xmlel{} :: xmlel() | [xmlel()]}).
|
||||||
|
|
||||||
|
-type(iq_get()
|
||||||
|
:: #iq{
|
||||||
|
id :: binary(),
|
||||||
|
type :: get,
|
||||||
|
xmlns :: binary(),
|
||||||
|
lang :: binary(),
|
||||||
|
sub_el :: xmlel()
|
||||||
|
}
|
||||||
|
).
|
||||||
|
|
||||||
|
-type(iq_set()
|
||||||
|
:: #iq{
|
||||||
|
id :: binary(),
|
||||||
|
type :: set,
|
||||||
|
xmlns :: binary(),
|
||||||
|
lang :: binary(),
|
||||||
|
sub_el :: xmlel()
|
||||||
|
}
|
||||||
|
).
|
||||||
|
|
||||||
|
-type iq_request() :: iq_get() | iq_set().
|
||||||
|
|
||||||
|
-type(iq_result()
|
||||||
|
:: #iq{
|
||||||
|
id :: binary(),
|
||||||
|
type :: result,
|
||||||
|
xmlns :: binary(),
|
||||||
|
lang :: binary(),
|
||||||
|
sub_el :: [xmlel()]
|
||||||
|
}
|
||||||
|
).
|
||||||
|
|
||||||
|
-type(iq_error()
|
||||||
|
:: #iq{
|
||||||
|
id :: binary(),
|
||||||
|
type :: error,
|
||||||
|
xmlns :: binary(),
|
||||||
|
lang :: binary(),
|
||||||
|
sub_el :: [xmlel()]
|
||||||
|
}
|
||||||
|
).
|
||||||
|
|
||||||
|
-type iq_reply() :: iq_result() | iq_error() .
|
||||||
|
|
||||||
|
-type(iq() :: iq_request() | iq_reply()).
|
||||||
|
|
||||||
|
-record(rsm_in, {max :: integer(),
|
||||||
|
direction :: before | aft,
|
||||||
|
id :: binary(),
|
||||||
|
index :: integer()}).
|
||||||
|
|
||||||
|
-record(rsm_out, {count :: integer(),
|
||||||
|
index :: integer(),
|
||||||
|
first :: binary(),
|
||||||
|
last :: binary()}).
|
||||||
|
|
||||||
|
-type(rsm_in() :: #rsm_in{}).
|
||||||
|
|
||||||
|
-type(rsm_out() :: #rsm_out{}).
|
||||||
|
|
||||||
|
-type broadcast() :: {broadcast, broadcast_data()}.
|
||||||
|
|
||||||
|
-type broadcast_data() ::
|
||||||
|
{rebind, pid(), binary()} | %% ejabberd_c2s
|
||||||
|
{item, ljid(), mod_roster:subscription()} | %% mod_roster/mod_shared_roster
|
||||||
|
{exit, binary()} | %% mod_roster/mod_shared_roster
|
||||||
|
{privacy_list, mod_privacy:userlist(), binary()} | %% mod_privacy
|
||||||
|
{blocking, unblock_all | {block | unblock, [ljid()]}}. %% mod_blocking
|
||||||
|
|
||||||
|
-record(xmlelement, {name = "" :: string(),
|
||||||
|
attrs = [] :: [{string(), string()}],
|
||||||
|
children = [] :: [{xmlcdata, iodata()} | xmlelement()]}).
|
||||||
|
|
||||||
|
-type xmlelement() :: #xmlelement{}.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%%
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
|
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
%%% modify it under the terms of the GNU General Public License as
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
@ -22,69 +22,95 @@
|
||||||
-define(MAX_USERS_DEFAULT, 200).
|
-define(MAX_USERS_DEFAULT, 200).
|
||||||
|
|
||||||
-define(SETS, gb_sets).
|
-define(SETS, gb_sets).
|
||||||
|
|
||||||
-define(DICT, dict).
|
-define(DICT, dict).
|
||||||
|
|
||||||
-record(lqueue, {queue, len, max}).
|
-record(lqueue,
|
||||||
|
{
|
||||||
|
queue :: queue(),
|
||||||
|
len :: integer(),
|
||||||
|
max :: integer()
|
||||||
|
}).
|
||||||
|
|
||||||
-record(config, {title = "",
|
-type lqueue() :: #lqueue{}.
|
||||||
description = "",
|
|
||||||
allow_change_subj = true,
|
|
||||||
allow_query_users = true,
|
|
||||||
allow_private_messages = true,
|
|
||||||
allow_private_messages_from_visitors = anyone,
|
|
||||||
allow_visitor_status = true,
|
|
||||||
allow_visitor_nickchange = true,
|
|
||||||
public = true,
|
|
||||||
public_list = true,
|
|
||||||
persistent = false,
|
|
||||||
moderated = true,
|
|
||||||
captcha_protected = false,
|
|
||||||
members_by_default = true,
|
|
||||||
members_only = false,
|
|
||||||
allow_user_invites = false,
|
|
||||||
password_protected = false,
|
|
||||||
password = "",
|
|
||||||
anonymous = true,
|
|
||||||
allow_voice_requests = true,
|
|
||||||
voice_request_min_interval = 1800,
|
|
||||||
max_users = ?MAX_USERS_DEFAULT,
|
|
||||||
logging = false,
|
|
||||||
captcha_whitelist = ?SETS:empty()
|
|
||||||
}).
|
|
||||||
|
|
||||||
-record(user, {jid,
|
-record(config,
|
||||||
nick,
|
{
|
||||||
role,
|
title = <<"">> :: binary(),
|
||||||
last_presence}).
|
description = <<"">> :: binary(),
|
||||||
|
allow_change_subj = true :: boolean(),
|
||||||
|
allow_query_users = true :: boolean(),
|
||||||
|
allow_private_messages = true :: boolean(),
|
||||||
|
allow_private_messages_from_visitors = anyone :: anyone | moderators | nobody ,
|
||||||
|
allow_visitor_status = true :: boolean(),
|
||||||
|
allow_visitor_nickchange = true :: boolean(),
|
||||||
|
public = true :: boolean(),
|
||||||
|
public_list = true :: boolean(),
|
||||||
|
persistent = false :: boolean(),
|
||||||
|
moderated = true :: boolean(),
|
||||||
|
captcha_protected = false :: boolean(),
|
||||||
|
members_by_default = true :: boolean(),
|
||||||
|
members_only = false :: boolean(),
|
||||||
|
allow_user_invites = false :: boolean(),
|
||||||
|
password_protected = false :: boolean(),
|
||||||
|
password = <<"">> :: binary(),
|
||||||
|
anonymous = true :: boolean(),
|
||||||
|
allow_voice_requests = true :: boolean(),
|
||||||
|
voice_request_min_interval = 1800 :: non_neg_integer(),
|
||||||
|
max_users = ?MAX_USERS_DEFAULT :: non_neg_integer() | none,
|
||||||
|
logging = false :: boolean(),
|
||||||
|
captcha_whitelist = (?SETS):empty() :: gb_set()
|
||||||
|
}).
|
||||||
|
|
||||||
-record(activity, {message_time = 0,
|
-type config() :: #config{}.
|
||||||
presence_time = 0,
|
|
||||||
message_shaper,
|
|
||||||
presence_shaper,
|
|
||||||
message,
|
|
||||||
presence}).
|
|
||||||
|
|
||||||
-record(state, {room,
|
-type role() :: moderator | participant | visitor | none.
|
||||||
host,
|
|
||||||
server_host,
|
|
||||||
mod,
|
|
||||||
access,
|
|
||||||
jid,
|
|
||||||
config = #config{},
|
|
||||||
users = ?DICT:new(),
|
|
||||||
last_voice_request_time = treap:empty(),
|
|
||||||
robots = ?DICT:new(),
|
|
||||||
nicks = ?DICT:new(),
|
|
||||||
affiliations = ?DICT:new(),
|
|
||||||
history,
|
|
||||||
subject = "",
|
|
||||||
subject_author = "",
|
|
||||||
just_created = false,
|
|
||||||
activity = treap:empty(),
|
|
||||||
room_shaper,
|
|
||||||
room_queue = queue:new()}).
|
|
||||||
|
|
||||||
-record(muc_online_users, {us,
|
-record(user,
|
||||||
resource,
|
{
|
||||||
room,
|
jid :: jid(),
|
||||||
host}).
|
nick :: binary(),
|
||||||
|
role :: role(),
|
||||||
|
last_presence :: xmlel()
|
||||||
|
}).
|
||||||
|
|
||||||
|
-record(activity,
|
||||||
|
{
|
||||||
|
message_time = 0 :: integer(),
|
||||||
|
presence_time = 0 :: integer(),
|
||||||
|
message_shaper :: shaper:shaper(),
|
||||||
|
presence_shaper :: shaper:shaper(),
|
||||||
|
message :: xmlel(),
|
||||||
|
presence :: {binary(), xmlel()}
|
||||||
|
}).
|
||||||
|
|
||||||
|
-record(state,
|
||||||
|
{
|
||||||
|
room = <<"">> :: binary(),
|
||||||
|
host = <<"">> :: binary(),
|
||||||
|
server_host = <<"">> :: binary(),
|
||||||
|
access = {none,none,none,none} :: {atom(), atom(), atom(), atom()},
|
||||||
|
jid = #jid{} :: jid(),
|
||||||
|
config = #config{} :: config(),
|
||||||
|
users = (?DICT):new() :: dict(),
|
||||||
|
last_voice_request_time = treap:empty() :: treap:treap(),
|
||||||
|
robots = (?DICT):new() :: dict(),
|
||||||
|
nicks = (?DICT):new() :: dict(),
|
||||||
|
affiliations = (?DICT):new() :: dict(),
|
||||||
|
history :: lqueue(),
|
||||||
|
subject = <<"">> :: binary(),
|
||||||
|
subject_author = <<"">> :: binary(),
|
||||||
|
just_created = false :: boolean(),
|
||||||
|
activity = treap:empty() :: treap:treap(),
|
||||||
|
room_shaper = none :: shaper:shaper(),
|
||||||
|
room_queue = queue:new() :: queue()
|
||||||
|
}).
|
||||||
|
|
||||||
|
-record(muc_online_users, {us = {<<>>, <<>>} :: {binary(), binary()},
|
||||||
|
resource = <<>> :: binary() | '_',
|
||||||
|
room = <<>> :: binary() | '_',
|
||||||
|
host = <<>> :: binary() | '_'}).
|
||||||
|
|
||||||
|
-type muc_online_users() :: #muc_online_users{}.
|
||||||
|
|
||||||
|
-type muc_room_state() :: #state{}.
|
||||||
|
|
|
@ -5,25 +5,28 @@
|
||||||
%%% Erlang Public License along with this software. If not, it can be
|
%%% Erlang Public License along with this software. If not, it can be
|
||||||
%%% retrieved via the world wide web at http://www.erlang.org/.
|
%%% retrieved via the world wide web at http://www.erlang.org/.
|
||||||
%%%
|
%%%
|
||||||
|
%%%
|
||||||
%%% Software distributed under the License is distributed on an "AS IS"
|
%%% Software distributed under the License is distributed on an "AS IS"
|
||||||
%%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
%%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
|
||||||
%%% the License for the specific language governing rights and limitations
|
%%% the License for the specific language governing rights and limitations
|
||||||
%%% under the License.
|
%%% under the License.
|
||||||
%%%
|
%%%
|
||||||
|
%%%
|
||||||
%%% The Initial Developer of the Original Code is ProcessOne.
|
%%% The Initial Developer of the Original Code is ProcessOne.
|
||||||
%%% Portions created by ProcessOne are Copyright 2006-2011, ProcessOne
|
%%% Portions created by ProcessOne are Copyright 2006-2013, ProcessOne
|
||||||
%%% All Rights Reserved.''
|
%%% All Rights Reserved.''
|
||||||
%%% This software is copyright 2006-2011, ProcessOne.
|
%%% This software is copyright 2006-2013, ProcessOne.
|
||||||
%%%
|
%%%
|
||||||
%%%
|
%%%
|
||||||
%%% copyright 2006-2011 ProcessOne
|
%%% copyright 2006-2013 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This file contains pubsub types definition.
|
%%% This file contains pubsub types definition.
|
||||||
%%% ====================================================================
|
%%% ====================================================================
|
||||||
|
|
||||||
%% -------------------------------
|
%% -------------------------------
|
||||||
%% Pubsub constants
|
%% Pubsub constants
|
||||||
-define(ERR_EXTENDED(E,C), mod_pubsub:extended_error(E,C)).
|
-define(ERR_EXTENDED(E, C),
|
||||||
|
mod_pubsub:extended_error(E, C)).
|
||||||
|
|
||||||
%% The actual limit can be configured with mod_pubsub's option max_items_node
|
%% The actual limit can be configured with mod_pubsub's option max_items_node
|
||||||
-define(MAXITEMS, 10).
|
-define(MAXITEMS, 10).
|
||||||
|
@ -36,9 +39,11 @@
|
||||||
%% Pubsub types
|
%% Pubsub types
|
||||||
|
|
||||||
%% @type hostPubsub() = string().
|
%% @type hostPubsub() = string().
|
||||||
|
-type(hostPubsub() :: binary()).
|
||||||
%% <p><tt>hostPubsub</tt> is the name of the PubSub service. For example, it can be
|
%% <p><tt>hostPubsub</tt> is the name of the PubSub service. For example, it can be
|
||||||
%% <tt>"pubsub.localhost"</tt>.</p>
|
%% <tt>"pubsub.localhost"</tt>.</p>
|
||||||
|
|
||||||
|
-type(hostPEP() :: {binary(), binary(), <<>>}).
|
||||||
%% @type hostPEP() = {User, Server, Resource}
|
%% @type hostPEP() = {User, Server, Resource}
|
||||||
%% User = string()
|
%% User = string()
|
||||||
%% Server = string()
|
%% Server = string()
|
||||||
|
@ -46,23 +51,31 @@
|
||||||
%% <p>For example, it can be :
|
%% <p>For example, it can be :
|
||||||
%% ```{"bob", "example.org", []}'''.</p>
|
%% ```{"bob", "example.org", []}'''.</p>
|
||||||
|
|
||||||
|
-type(host() :: hostPubsub() | hostPEP()).
|
||||||
%% @type host() = hostPubsub() | hostPEP().
|
%% @type host() = hostPubsub() | hostPEP().
|
||||||
|
|
||||||
|
-type(nodeId() :: binary()).
|
||||||
%% @type nodeId() = binary().
|
%% @type nodeId() = binary().
|
||||||
%% <p>A node is defined by a list of its ancestors. The last element is the name
|
%% <p>A node is defined by a list of its ancestors. The last element is the name
|
||||||
%% of the current node. For example:
|
%% of the current node. For example:
|
||||||
|
%% of the current node. For example:
|
||||||
%% ```<<"/home/localhost/user">>'''</p>
|
%% ```<<"/home/localhost/user">>'''</p>
|
||||||
|
|
||||||
|
-type(nodeIdx() :: pos_integer()).
|
||||||
%% @type nodeIdx() = integer().
|
%% @type nodeIdx() = integer().
|
||||||
|
|
||||||
|
-type(itemId() :: binary()).
|
||||||
%% @type itemId() = string().
|
%% @type itemId() = string().
|
||||||
|
|
||||||
|
-type(subId() :: binary()).
|
||||||
%% @type subId() = string().
|
%% @type subId() = string().
|
||||||
|
|
||||||
|
|
||||||
%% @type payload() = [#xmlelement{} | #xmlcdata{}].
|
%% @type payload() = [#xmlelement{} | #xmlcdata{}].
|
||||||
|
|
||||||
%% @type stanzaError() = #xmlelement{}.
|
%% @type stanzaError() = #xmlelement{}.
|
||||||
%% Example:
|
%% Example:
|
||||||
|
%% Example:
|
||||||
%% ```{xmlelement, "error",
|
%% ```{xmlelement, "error",
|
||||||
%% [{"code", Code}, {"type", Type}],
|
%% [{"code", Code}, {"type", Type}],
|
||||||
%% [{xmlelement, Condition, [{"xmlns", ?NS_STANZAS}], []}]}'''
|
%% [{xmlelement, Condition, [{"xmlns", ?NS_STANZAS}], []}]}'''
|
||||||
|
@ -73,12 +86,26 @@
|
||||||
%% [{xmlelement, "affiliations", [],
|
%% [{xmlelement, "affiliations", [],
|
||||||
%% []}]}'''
|
%% []}]}'''
|
||||||
|
|
||||||
|
-type(nodeOption() ::
|
||||||
|
{Option::atom(),
|
||||||
|
Value::binary() | [binary()] | boolean() | non_neg_integer()
|
||||||
|
}).
|
||||||
|
|
||||||
|
-type(nodeOptions() :: [NodeOption::mod_pubsub:nodeOption(),...]).
|
||||||
|
|
||||||
%% @type nodeOption() = {Option, Value}
|
%% @type nodeOption() = {Option, Value}
|
||||||
%% Option = atom()
|
%% Option = atom()
|
||||||
%% Value = term().
|
%% Value = term().
|
||||||
%% Example:
|
%% Example:
|
||||||
%% ```{deliver_payloads, true}'''
|
%% ```{deliver_payloads, true}'''
|
||||||
|
|
||||||
|
-type(subOption() ::
|
||||||
|
{Option::atom(),
|
||||||
|
Value::binary() | [binary()] | boolean()
|
||||||
|
}).
|
||||||
|
|
||||||
|
-type(subOptions() :: [SubOption::mod_pubsub:subOption(),...]).
|
||||||
|
|
||||||
%% @type nodeType() = string().
|
%% @type nodeType() = string().
|
||||||
%% <p>The <tt>nodeType</tt> is a string containing the name of the PubSub
|
%% <p>The <tt>nodeType</tt> is a string containing the name of the PubSub
|
||||||
%% plugin to use to manage a given node. For example, it can be
|
%% plugin to use to manage a given node. For example, it can be
|
||||||
|
@ -92,15 +119,34 @@
|
||||||
%% LServer = string()
|
%% LServer = string()
|
||||||
%% LResource = string().
|
%% LResource = string().
|
||||||
|
|
||||||
|
%-type(ljid() :: {binary(), binary(), binary()}).
|
||||||
%% @type ljid() = {User, Server, Resource}
|
%% @type ljid() = {User, Server, Resource}
|
||||||
%% User = string()
|
%% User = string()
|
||||||
%% Server = string()
|
%% Server = string()
|
||||||
%% Resource = string().
|
%% Resource = string().
|
||||||
|
|
||||||
|
-type(affiliation() :: 'none'
|
||||||
|
| 'owner'
|
||||||
|
| 'publisher'
|
||||||
|
%| 'publish-only'
|
||||||
|
| 'member'
|
||||||
|
| 'outcast'
|
||||||
|
).
|
||||||
%% @type affiliation() = 'none' | 'owner' | 'publisher' | 'publish-only' | 'member' | 'outcast'.
|
%% @type affiliation() = 'none' | 'owner' | 'publisher' | 'publish-only' | 'member' | 'outcast'.
|
||||||
|
|
||||||
|
-type(subscription() :: 'none'
|
||||||
|
| 'pending'
|
||||||
|
| 'unconfigured'
|
||||||
|
| 'subscribed'
|
||||||
|
).
|
||||||
%% @type subscription() = 'none' | 'pending' | 'unconfigured' | 'subscribed'.
|
%% @type subscription() = 'none' | 'pending' | 'unconfigured' | 'subscribed'.
|
||||||
|
|
||||||
|
-type(accessModel() :: 'open'
|
||||||
|
| 'presence'
|
||||||
|
| 'roster'
|
||||||
|
| 'authorize'
|
||||||
|
| 'whitelist'
|
||||||
|
).
|
||||||
%% @type accessModel() = 'open' | 'presence' | 'roster' | 'authorize' | 'whitelist'.
|
%% @type accessModel() = 'open' | 'presence' | 'roster' | 'authorize' | 'whitelist'.
|
||||||
|
|
||||||
%% @type pubsubIndex() = {pubsub_index, Index, Last, Free}
|
%% @type pubsubIndex() = {pubsub_index, Index, Last, Free}
|
||||||
|
@ -108,11 +154,17 @@
|
||||||
%% Last = integer()
|
%% Last = integer()
|
||||||
%% Free = [integer()].
|
%% Free = [integer()].
|
||||||
%% internal pubsub index table
|
%% internal pubsub index table
|
||||||
|
-type(publishModel() :: 'publishers'
|
||||||
|
| 'subscribers'
|
||||||
|
| 'open'
|
||||||
|
).
|
||||||
|
|
||||||
|
|
||||||
-record(pubsub_index,
|
-record(pubsub_index,
|
||||||
{
|
{
|
||||||
index,
|
index :: atom(),
|
||||||
last,
|
last :: mod_pubsub:nodeIdx(),
|
||||||
free
|
free :: [mod_pubsub:nodeIdx()]
|
||||||
}).
|
}).
|
||||||
|
|
||||||
%% @type pubsubNode() = {pubsub_node, NodeId, Id, Parents, Type, Owners, Options}
|
%% @type pubsubNode() = {pubsub_node, NodeId, Id, Parents, Type, Owners, Options}
|
||||||
|
@ -128,12 +180,12 @@
|
||||||
%% <tt>id</tt> can be anything you want.
|
%% <tt>id</tt> can be anything you want.
|
||||||
-record(pubsub_node,
|
-record(pubsub_node,
|
||||||
{
|
{
|
||||||
nodeid,
|
nodeid ,%:: {Host::mod_pubsub:host(), NodeId::mod_pubsub:nodeId()},
|
||||||
id,
|
id ,%:: mod_pubsub:nodeIdx(),
|
||||||
parents = [],
|
parents = [] ,%:: [Parent_NodeId::mod_pubsub:nodeId()],
|
||||||
type = "flat",
|
type = <<"flat">> ,%:: binary(),
|
||||||
owners = [],
|
owners = [] ,%:: [Owner::ljid(),...],
|
||||||
options = []
|
options = [] %:: mod_pubsub:nodeOptions()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
%% @type pubsubState() = {pubsub_state, StateId, Items, Affiliation, Subscriptions}
|
%% @type pubsubState() = {pubsub_state, StateId, Items, Affiliation, Subscriptions}
|
||||||
|
@ -143,12 +195,16 @@
|
||||||
%% Subscriptions = [{subscription(), subId()}].
|
%% Subscriptions = [{subscription(), subId()}].
|
||||||
%% <p>This is the format of the <tt>affiliations</tt> table. The type of the
|
%% <p>This is the format of the <tt>affiliations</tt> table. The type of the
|
||||||
%% table is: <tt>set</tt>,<tt>ram/disc</tt>.</p>
|
%% table is: <tt>set</tt>,<tt>ram/disc</tt>.</p>
|
||||||
|
|
||||||
|
%-record(pubsub_state,
|
||||||
|
% {stateid, items = [], affiliation = none,
|
||||||
|
% subscriptions = []}).
|
||||||
-record(pubsub_state,
|
-record(pubsub_state,
|
||||||
{
|
{
|
||||||
stateid,
|
stateid ,%:: {Entity::ljid(), NodeIdx::mod_pubsub:nodeIdx()},
|
||||||
items = [],
|
items = [] ,%:: [ItemId::mod_pubsub:itemId()],
|
||||||
affiliation = 'none',
|
affiliation = 'none' ,%:: mod_pubsub:affiliation(),
|
||||||
subscriptions = []
|
subscriptions = [] %:: [{mod_pubsub:subscription(), mod_pubsub:subId()}]
|
||||||
}).
|
}).
|
||||||
|
|
||||||
%% @type pubsubItem() = {pubsub_item, ItemId, Creation, Modification, Payload}
|
%% @type pubsubItem() = {pubsub_item, ItemId, Creation, Modification, Payload}
|
||||||
|
@ -158,12 +214,16 @@
|
||||||
%% Payload = payload().
|
%% Payload = payload().
|
||||||
%% <p>This is the format of the <tt>published items</tt> table. The type of the
|
%% <p>This is the format of the <tt>published items</tt> table. The type of the
|
||||||
%% table is: <tt>set</tt>,<tt>disc</tt>,<tt>fragmented</tt>.</p>
|
%% table is: <tt>set</tt>,<tt>disc</tt>,<tt>fragmented</tt>.</p>
|
||||||
|
%-record(pubsub_item,
|
||||||
|
% {itemid, creation = {unknown, unknown},
|
||||||
|
% modification = {unknown, unknown}, payload = []}).
|
||||||
|
|
||||||
-record(pubsub_item,
|
-record(pubsub_item,
|
||||||
{
|
{
|
||||||
itemid,
|
itemid ,%:: {mod_pubsub:itemId(), mod_pubsub:nodeIdx()},
|
||||||
creation = {'unknown','unknown'},
|
creation = {unknown, unknown} ,%:: {erlang:timestamp(), ljid()},
|
||||||
modification = {'unknown','unknown'},
|
modification = {unknown, unknown} ,%:: {erlang:timestamp(), ljid()},
|
||||||
payload = []
|
payload = [] %:: mod_pubsub:payload()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
%% @type pubsubSubscription() = {pubsub_subscription, SubId, Options}
|
%% @type pubsubSubscription() = {pubsub_subscription, SubId, Options}
|
||||||
|
@ -171,10 +231,11 @@
|
||||||
%% Options = [nodeOption()].
|
%% Options = [nodeOption()].
|
||||||
%% <p>This is the format of the <tt>subscriptions</tt> table. The type of the
|
%% <p>This is the format of the <tt>subscriptions</tt> table. The type of the
|
||||||
%% table is: <tt>set</tt>,<tt>ram/disc</tt>.</p>
|
%% table is: <tt>set</tt>,<tt>ram/disc</tt>.</p>
|
||||||
|
%-record(pubsub_subscription, {subid, options}).
|
||||||
-record(pubsub_subscription,
|
-record(pubsub_subscription,
|
||||||
{
|
{
|
||||||
subid,
|
subid ,%:: mod_pubsub:subId(),
|
||||||
options
|
options %:: [] | mod_pubsub:subOptions()
|
||||||
}).
|
}).
|
||||||
|
|
||||||
%% @type pubsubLastItem() = {pubsub_last_item, NodeId, ItemId, Creation, Payload}
|
%% @type pubsubLastItem() = {pubsub_last_item, NodeId, ItemId, Creation, Payload}
|
||||||
|
@ -184,10 +245,13 @@
|
||||||
%% Payload = payload().
|
%% Payload = payload().
|
||||||
%% <p>This is the format of the <tt>last items</tt> table. it stores last item payload
|
%% <p>This is the format of the <tt>last items</tt> table. it stores last item payload
|
||||||
%% for every node</p>
|
%% for every node</p>
|
||||||
|
%-record(pubsub_last_item,
|
||||||
|
% {nodeid, itemid, creation, payload}).
|
||||||
|
|
||||||
-record(pubsub_last_item,
|
-record(pubsub_last_item,
|
||||||
{
|
{
|
||||||
nodeid,
|
nodeid ,%:: mod_pubsub:nodeIdx(),
|
||||||
itemid,
|
itemid ,%:: mod_pubsub:itemId(),
|
||||||
creation,
|
creation ,%:: {erlang:timestamp(), ljid()},
|
||||||
payload
|
payload %:: mod_pubsub:payload()
|
||||||
}).
|
}).
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%%
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
|
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
%%% modify it under the terms of the GNU General Public License as
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
@ -19,15 +19,24 @@
|
||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-record(roster, {usj,
|
-record(roster,
|
||||||
us,
|
{
|
||||||
jid,
|
usj = {<<>>, <<>>, {<<>>, <<>>, <<>>}} :: {binary(), binary(), ljid()} | '_',
|
||||||
name = "",
|
us = {<<>>, <<>>} :: {binary(), binary()} | '_',
|
||||||
subscription = none,
|
jid = {<<>>, <<>>, <<>>} :: ljid(),
|
||||||
ask = none,
|
name = <<>> :: binary() | '_',
|
||||||
groups = [],
|
subscription = none :: subscription() | '_',
|
||||||
askmessage = [],
|
ask = none :: ask() | '_',
|
||||||
xs = []}).
|
groups = [] :: [binary()] | '_',
|
||||||
|
askmessage = <<"">> :: binary() | '_',
|
||||||
|
xs = [] :: [xmlel()] | '_'
|
||||||
|
}).
|
||||||
|
|
||||||
-record(roster_version, {us,
|
-record(roster_version,
|
||||||
version}).
|
{
|
||||||
|
us = {<<>>, <<>>} :: {binary(), binary()},
|
||||||
|
version = <<>> :: binary()
|
||||||
|
}).
|
||||||
|
|
||||||
|
-type ask() :: none | in | out | both | subscribe | unsubscribe.
|
||||||
|
-type subscription() :: none | both | from | to | remove.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%%
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
|
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
%%% modify it under the terms of the GNU General Public License as
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
@ -19,16 +19,18 @@
|
||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-record(request, {method,
|
-record(request,
|
||||||
path,
|
{method, % :: method(),
|
||||||
q = [],
|
path = [] :: [binary()],
|
||||||
us,
|
q = [] :: [{binary() | nokey, binary()}],
|
||||||
auth,
|
us = {<<>>, <<>>} :: {binary(), binary()},
|
||||||
lang = "",
|
auth :: {binary(), binary()} |
|
||||||
data = "",
|
{auth_jid, {binary(), binary()}, jlib:jid()},
|
||||||
ip,
|
lang = <<"">> :: binary(),
|
||||||
host, % string()
|
data = <<"">> :: binary(),
|
||||||
port, % integer()
|
ip :: {inet:ip_address(), inet:port_number()},
|
||||||
tp, % transfer protocol = http | https
|
host = <<"">> :: binary(),
|
||||||
headers
|
port = 5280 :: inet:port_number(),
|
||||||
}).
|
tp = http, % :: protocol(),
|
||||||
|
headers = [] :: [{atom() | binary(), binary()}]}).
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%%
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2002-2012 ProcessOne
|
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
%%% modify it under the terms of the GNU General Public License as
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
@ -19,58 +19,87 @@
|
||||||
%%%
|
%%%
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-define(X(Name), {xmlelement, Name, [], []}).
|
-define(X(Name),
|
||||||
-define(XA(Name, Attrs), {xmlelement, Name, Attrs, []}).
|
#xmlel{name = Name, attrs = [], children = []}).
|
||||||
-define(XE(Name, Els), {xmlelement, Name, [], Els}).
|
|
||||||
-define(XAE(Name, Attrs, Els), {xmlelement, Name, Attrs, Els}).
|
-define(XA(Name, Attrs),
|
||||||
|
#xmlel{name = Name, attrs = Attrs, children = []}).
|
||||||
|
|
||||||
|
-define(XE(Name, Els),
|
||||||
|
#xmlel{name = Name, attrs = [], children = Els}).
|
||||||
|
|
||||||
|
-define(XAE(Name, Attrs, Els),
|
||||||
|
#xmlel{name = Name, attrs = Attrs, children = Els}).
|
||||||
|
|
||||||
-define(C(Text), {xmlcdata, Text}).
|
-define(C(Text), {xmlcdata, Text}).
|
||||||
|
|
||||||
-define(XC(Name, Text), ?XE(Name, [?C(Text)])).
|
-define(XC(Name, Text), ?XE(Name, [?C(Text)])).
|
||||||
-define(XAC(Name, Attrs, Text), ?XAE(Name, Attrs, [?C(Text)])).
|
|
||||||
|
-define(XAC(Name, Attrs, Text),
|
||||||
|
?XAE(Name, Attrs, [?C(Text)])).
|
||||||
|
|
||||||
-define(T(Text), translate:translate(Lang, Text)).
|
-define(T(Text), translate:translate(Lang, Text)).
|
||||||
-define(CT(Text), ?C(?T(Text))).
|
|
||||||
-define(XCT(Name, Text), ?XC(Name, ?T(Text))).
|
|
||||||
-define(XACT(Name, Attrs, Text), ?XAC(Name, Attrs, ?T(Text))).
|
|
||||||
|
|
||||||
-define(LI(Els), ?XE("li", Els)).
|
-define(CT(Text), ?C((?T(Text)))).
|
||||||
-define(A(URL, Els), ?XAE("a", [{"href", URL}], Els)).
|
|
||||||
|
-define(XCT(Name, Text), ?XC(Name, (?T(Text)))).
|
||||||
|
|
||||||
|
-define(XACT(Name, Attrs, Text),
|
||||||
|
?XAC(Name, Attrs, (?T(Text)))).
|
||||||
|
|
||||||
|
-define(LI(Els), ?XE(<<"li">>, Els)).
|
||||||
|
|
||||||
|
-define(A(URL, Els),
|
||||||
|
?XAE(<<"a">>, [{<<"href">>, URL}], Els)).
|
||||||
|
|
||||||
-define(AC(URL, Text), ?A(URL, [?C(Text)])).
|
-define(AC(URL, Text), ?A(URL, [?C(Text)])).
|
||||||
-define(ACT(URL, Text), ?AC(URL, ?T(Text))).
|
|
||||||
-define(P, ?X("p")).
|
-define(ACT(URL, Text), ?AC(URL, (?T(Text)))).
|
||||||
-define(BR, ?X("br")).
|
|
||||||
|
-define(P, ?X(<<"p">>)).
|
||||||
|
|
||||||
|
-define(BR, ?X(<<"br">>)).
|
||||||
|
|
||||||
-define(INPUT(Type, Name, Value),
|
-define(INPUT(Type, Name, Value),
|
||||||
?XA("input", [{"type", Type},
|
?XA(<<"input">>,
|
||||||
{"name", Name},
|
[{<<"type">>, Type}, {<<"name">>, Name},
|
||||||
{"value", Value}])).
|
{<<"value">>, Value}])).
|
||||||
-define(INPUTT(Type, Name, Value), ?INPUT(Type, Name, ?T(Value))).
|
|
||||||
|
-define(INPUTT(Type, Name, Value),
|
||||||
|
?INPUT(Type, Name, (?T(Value)))).
|
||||||
|
|
||||||
-define(INPUTS(Type, Name, Value, Size),
|
-define(INPUTS(Type, Name, Value, Size),
|
||||||
?XA("input", [{"type", Type},
|
?XA(<<"input">>,
|
||||||
{"name", Name},
|
[{<<"type">>, Type}, {<<"name">>, Name},
|
||||||
{"value", Value},
|
{<<"value">>, Value}, {<<"size">>, Size}])).
|
||||||
{"size", Size}])).
|
|
||||||
-define(INPUTST(Type, Name, Value, Size), ?INPUT(Type, Name, ?T(Value), Size)).
|
-define(INPUTST(Type, Name, Value, Size),
|
||||||
-define(ACLINPUT(Text), ?XE("td", [?INPUT("text", "value" ++ ID, Text)])).
|
?INPUT(Type, Name, (?T(Value)), Size)).
|
||||||
|
|
||||||
|
-define(ACLINPUT(Text),
|
||||||
|
?XE(<<"td">>,
|
||||||
|
[?INPUT(<<"text">>, <<"value", ID/binary>>, Text)])).
|
||||||
|
|
||||||
-define(TEXTAREA(Name, Rows, Cols, Value),
|
-define(TEXTAREA(Name, Rows, Cols, Value),
|
||||||
?XAC("textarea", [{"name", Name},
|
?XAC(<<"textarea">>,
|
||||||
{"rows", Rows},
|
[{<<"name">>, Name}, {<<"rows">>, Rows},
|
||||||
{"cols", Cols}],
|
{<<"cols">>, Cols}],
|
||||||
Value)).
|
Value)).
|
||||||
|
|
||||||
%% Build an xmlelement for result
|
%% Build an xmlelement for result
|
||||||
-define(XRES(Text), ?XAC("p", [{"class", "result"}], Text)).
|
-define(XRES(Text),
|
||||||
-define(XREST(Text), ?XRES(?T(Text))).
|
?XAC(<<"p">>, [{<<"class">>, <<"result">>}], Text)).
|
||||||
|
|
||||||
%% Guide Link
|
%% Guide Link
|
||||||
-define(GL(Ref, Title),
|
-define(XREST(Text), ?XRES((?T(Text)))).
|
||||||
?XAE("div",
|
|
||||||
[{"class", "guidelink"}],
|
|
||||||
[?XAE("a",
|
|
||||||
[{"href", "/admin/doc/guide.html#"++ Ref},
|
|
||||||
{"target", "_blank"}],
|
|
||||||
[?C("[Guide: " ++ Title ++ "]")])
|
|
||||||
])).
|
|
||||||
|
|
||||||
|
-define(GL(Ref, Title),
|
||||||
|
?XAE(<<"div">>, [{<<"class">>, <<"guidelink">>}],
|
||||||
|
[?XAE(<<"a">>,
|
||||||
|
[{<<"href">>, <<"/admin/doc/guide.html#", Ref/binary>>},
|
||||||
|
{<<"target">>, <<"_blank">>}],
|
||||||
|
[?C(<<"[Guide: ", Title/binary, "]">>)])])).
|
||||||
|
|
||||||
%% h1 with a Guide Link
|
%% h1 with a Guide Link
|
||||||
-define(H1GL(Name, Ref, Title), [?XC("h1", Name), ?GL(Ref, Title)]).
|
-define(H1GL(Name, Ref, Title),
|
||||||
|
[?XC(<<"h1">>, Name), ?GL(Ref, Title)]).
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
%%% File : gen_mod.erl
|
%%% File : gen_mod.erl
|
||||||
%%% Author : Alexey Shchepin <alexey@process-one.net>
|
%%% Author : Alexey Shchepin <alexey@process-one.net>
|
||||||
%%% Purpose :
|
%%% Purpose :
|
||||||
|
%%% Purpose :
|
||||||
%%% Created : 24 Jan 2003 by Alexey Shchepin <alexey@process-one.net>
|
%%% Created : 24 Jan 2003 by Alexey Shchepin <alexey@process-one.net>
|
||||||
%%%
|
%%%
|
||||||
%%%
|
%%%
|
||||||
%%% ejabberd, Copyright (C) 2002-2008 ProcessOne
|
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
|
||||||
%%%
|
%%%
|
||||||
%%% This program is free software; you can redistribute it and/or
|
%%% This program is free software; you can redistribute it and/or
|
||||||
%%% modify it under the terms of the GNU General Public License as
|
%%% modify it under the terms of the GNU General Public License as
|
||||||
|
@ -25,63 +26,81 @@
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-module(gen_mod).
|
-module(gen_mod).
|
||||||
|
|
||||||
-author('alexey@process-one.net').
|
-author('alexey@process-one.net').
|
||||||
|
|
||||||
-export([start/0,
|
-export([start/0, start_module/3, stop_module/2,
|
||||||
start_module/3,
|
stop_module_keep_config/2, get_opt/3, get_opt/4,
|
||||||
stop_module/2,
|
get_opt_host/3, db_type/1, db_type/2, get_module_opt/5,
|
||||||
stop_module_keep_config/2,
|
get_module_opt_host/3, loaded_modules/1,
|
||||||
get_opt/2,
|
loaded_modules_with_opts/1, get_hosts/2,
|
||||||
get_opt/3,
|
get_module_proc/2, is_loaded/2]).
|
||||||
get_opt_host/3,
|
|
||||||
get_module_opt/4,
|
|
||||||
get_module_opt_host/3,
|
|
||||||
loaded_modules/1,
|
|
||||||
loaded_modules_with_opts/1,
|
|
||||||
get_hosts/2,
|
|
||||||
get_module_proc/2,
|
|
||||||
is_loaded/2]).
|
|
||||||
|
|
||||||
-export([behaviour_info/1]).
|
%%-export([behaviour_info/1]).
|
||||||
|
|
||||||
-include("ejabberd.hrl").
|
-include("ejabberd.hrl").
|
||||||
|
|
||||||
-record(ejabberd_module, {module_host, opts}).
|
-record(ejabberd_module,
|
||||||
|
{module_host = {undefined, <<"">>} :: {atom(), binary()},
|
||||||
|
opts = [] :: opts() | '_' | '$2'}).
|
||||||
|
|
||||||
behaviour_info(callbacks) ->
|
-type opts() :: [{atom(), any()}].
|
||||||
[{start, 2},
|
|
||||||
{stop, 1}];
|
-callback start(binary(), opts()) -> any().
|
||||||
behaviour_info(_Other) ->
|
-callback stop(binary()) -> any().
|
||||||
undefined.
|
|
||||||
|
-export_type([opts/0]).
|
||||||
|
|
||||||
|
%%behaviour_info(callbacks) -> [{start, 2}, {stop, 1}];
|
||||||
|
%%behaviour_info(_Other) -> undefined.
|
||||||
|
|
||||||
start() ->
|
start() ->
|
||||||
ets:new(ejabberd_modules, [named_table,
|
ets:new(ejabberd_modules,
|
||||||
public,
|
[named_table, public,
|
||||||
{keypos, #ejabberd_module.module_host}]),
|
{keypos, #ejabberd_module.module_host}]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
-spec start_module(binary(), atom(), opts()) -> any().
|
||||||
|
|
||||||
start_module(Host, Module, Opts) ->
|
start_module(Host, Module, Opts) ->
|
||||||
set_module_opts_mnesia(Host, Module, Opts),
|
set_module_opts_mnesia(Host, Module, Opts),
|
||||||
ets:insert(ejabberd_modules,
|
ets:insert(ejabberd_modules,
|
||||||
#ejabberd_module{module_host = {Module, Host},
|
#ejabberd_module{module_host = {Module, Host},
|
||||||
opts = Opts}),
|
opts = Opts}),
|
||||||
case catch Module:start(Host, Opts) of
|
try Module:start(Host, Opts) catch
|
||||||
{'EXIT', Reason} ->
|
Class:Reason ->
|
||||||
del_module_mnesia(Host, Module),
|
del_module_mnesia(Host, Module),
|
||||||
ets:delete(ejabberd_modules, {Module, Host}),
|
ets:delete(ejabberd_modules, {Module, Host}),
|
||||||
?ERROR_MSG("~p", [Reason]);
|
ErrorText =
|
||||||
_ ->
|
io_lib:format("Problem starting the module ~p for host "
|
||||||
ok
|
"~p ~n options: ~p~n ~p: ~p~n~p",
|
||||||
|
[Module, Host, Opts, Class, Reason,
|
||||||
|
erlang:get_stacktrace()]),
|
||||||
|
?CRITICAL_MSG(ErrorText, []),
|
||||||
|
case is_app_running(ejabberd) of
|
||||||
|
true ->
|
||||||
|
erlang:raise(Class, Reason, erlang:get_stacktrace());
|
||||||
|
false ->
|
||||||
|
?CRITICAL_MSG("ejabberd initialization was aborted "
|
||||||
|
"because a module start failed.",
|
||||||
|
[]),
|
||||||
|
timer:sleep(3000),
|
||||||
|
erlang:halt(string:substr(lists:flatten(ErrorText), 1, 199))
|
||||||
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
is_app_running(AppName) ->
|
||||||
|
Timeout = 15000,
|
||||||
|
lists:keymember(AppName, 1,
|
||||||
|
application:which_applications(Timeout)).
|
||||||
|
|
||||||
|
-spec stop_module(binary(), atom()) -> error | {aborted, any()} | {atomic, any()}.
|
||||||
|
|
||||||
%% @doc Stop the module in a host, and forget its configuration.
|
%% @doc Stop the module in a host, and forget its configuration.
|
||||||
stop_module(Host, Module) ->
|
stop_module(Host, Module) ->
|
||||||
case stop_module_keep_config(Host, Module) of
|
case stop_module_keep_config(Host, Module) of
|
||||||
error ->
|
error -> error;
|
||||||
error;
|
ok -> del_module_mnesia(Host, Module)
|
||||||
ok ->
|
|
||||||
del_module_mnesia(Host, Module)
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @doc Stop the module in a host, but keep its configuration.
|
%% @doc Stop the module in a host, but keep its configuration.
|
||||||
|
@ -89,11 +108,11 @@ stop_module(Host, Module) ->
|
||||||
%% when ejabberd is restarted the module will be started again.
|
%% when ejabberd is restarted the module will be started again.
|
||||||
%% This function is useful when ejabberd is being stopped
|
%% This function is useful when ejabberd is being stopped
|
||||||
%% and it stops all modules.
|
%% and it stops all modules.
|
||||||
|
-spec stop_module_keep_config(binary(), atom()) -> error | ok.
|
||||||
|
|
||||||
stop_module_keep_config(Host, Module) ->
|
stop_module_keep_config(Host, Module) ->
|
||||||
case catch Module:stop(Host) of
|
case catch Module:stop(Host) of
|
||||||
{'EXIT', Reason} ->
|
{'EXIT', Reason} -> ?ERROR_MSG("~p", [Reason]), error;
|
||||||
?ERROR_MSG("~p", [Reason]),
|
|
||||||
error;
|
|
||||||
{wait, ProcList} when is_list(ProcList) ->
|
{wait, ProcList} when is_list(ProcList) ->
|
||||||
lists:foreach(fun wait_for_process/1, ProcList),
|
lists:foreach(fun wait_for_process/1, ProcList),
|
||||||
ets:delete(ejabberd_modules, {Module, Host}),
|
ets:delete(ejabberd_modules, {Module, Host}),
|
||||||
|
@ -102,9 +121,7 @@ stop_module_keep_config(Host, Module) ->
|
||||||
wait_for_process(Process),
|
wait_for_process(Process),
|
||||||
ets:delete(ejabberd_modules, {Module, Host}),
|
ets:delete(ejabberd_modules, {Module, Host}),
|
||||||
ok;
|
ok;
|
||||||
_ ->
|
_ -> ets:delete(ejabberd_modules, {Module, Host}), ok
|
||||||
ets:delete(ejabberd_modules, {Module, Host}),
|
|
||||||
ok
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
wait_for_process(Process) ->
|
wait_for_process(Process) ->
|
||||||
|
@ -113,8 +130,7 @@ wait_for_process(Process) ->
|
||||||
|
|
||||||
wait_for_stop(Process, MonitorReference) ->
|
wait_for_stop(Process, MonitorReference) ->
|
||||||
receive
|
receive
|
||||||
{'DOWN', MonitorReference, _Type, _Object, _Info} ->
|
{'DOWN', MonitorReference, _Type, _Object, _Info} -> ok
|
||||||
ok
|
|
||||||
after 5000 ->
|
after 5000 ->
|
||||||
catch exit(whereis(Process), kill),
|
catch exit(whereis(Process), kill),
|
||||||
wait_for_stop1(MonitorReference)
|
wait_for_stop1(MonitorReference)
|
||||||
|
@ -122,38 +138,37 @@ wait_for_stop(Process, MonitorReference) ->
|
||||||
|
|
||||||
wait_for_stop1(MonitorReference) ->
|
wait_for_stop1(MonitorReference) ->
|
||||||
receive
|
receive
|
||||||
{'DOWN', MonitorReference, _Type, _Object, _Info} ->
|
{'DOWN', MonitorReference, _Type, _Object, _Info} -> ok
|
||||||
ok
|
after 5000 -> ok
|
||||||
after 5000 ->
|
|
||||||
ok
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_opt(Opt, Opts) ->
|
-type check_fun() :: fun((any()) -> any()) | {module(), atom()}.
|
||||||
case lists:keysearch(Opt, 1, Opts) of
|
|
||||||
false ->
|
|
||||||
% TODO: replace with more appropriate function
|
|
||||||
throw({undefined_option, Opt});
|
|
||||||
{value, {_, Val}} ->
|
|
||||||
Val
|
|
||||||
end.
|
|
||||||
|
|
||||||
get_opt(Opt, Opts, Default) ->
|
-spec get_opt(atom(), opts(), check_fun()) -> any().
|
||||||
|
|
||||||
|
get_opt(Opt, Opts, F) ->
|
||||||
|
get_opt(Opt, Opts, F, undefined).
|
||||||
|
|
||||||
|
-spec get_opt(atom(), opts(), check_fun(), any()) -> any().
|
||||||
|
|
||||||
|
get_opt(Opt, Opts, F, Default) ->
|
||||||
case lists:keysearch(Opt, 1, Opts) of
|
case lists:keysearch(Opt, 1, Opts) of
|
||||||
false ->
|
false ->
|
||||||
Default;
|
Default;
|
||||||
{value, {_, Val}} ->
|
{value, {_, Val}} ->
|
||||||
Val
|
ejabberd_config:prepare_opt_val(Opt, Val, F, Default)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_module_opt(global, Module, Opt, Default) ->
|
-spec get_module_opt(global | binary(), atom(), atom(), check_fun(), any()) -> any().
|
||||||
Hosts = ?MYHOSTS,
|
|
||||||
[Value | Values] = lists:map(
|
get_module_opt(global, Module, Opt, F, Default) ->
|
||||||
fun(Host) ->
|
Hosts = (?MYHOSTS),
|
||||||
get_module_opt(Host, Module, Opt, Default)
|
[Value | Values] = lists:map(fun (Host) ->
|
||||||
|
get_module_opt(Host, Module, Opt,
|
||||||
|
F, Default)
|
||||||
end,
|
end,
|
||||||
Hosts),
|
Hosts),
|
||||||
Same_all = lists:all(
|
Same_all = lists:all(fun (Other_value) ->
|
||||||
fun(Other_value) ->
|
|
||||||
Other_value == Value
|
Other_value == Value
|
||||||
end,
|
end,
|
||||||
Values),
|
Values),
|
||||||
|
@ -161,64 +176,90 @@ get_module_opt(global, Module, Opt, Default) ->
|
||||||
true -> Value;
|
true -> Value;
|
||||||
false -> Default
|
false -> Default
|
||||||
end;
|
end;
|
||||||
|
get_module_opt(Host, Module, Opt, F, Default) ->
|
||||||
get_module_opt(Host, Module, Opt, Default) ->
|
|
||||||
OptsList = ets:lookup(ejabberd_modules, {Module, Host}),
|
OptsList = ets:lookup(ejabberd_modules, {Module, Host}),
|
||||||
case OptsList of
|
case OptsList of
|
||||||
[] ->
|
[] -> Default;
|
||||||
Default;
|
|
||||||
[#ejabberd_module{opts = Opts} | _] ->
|
[#ejabberd_module{opts = Opts} | _] ->
|
||||||
get_opt(Opt, Opts, Default)
|
get_opt(Opt, Opts, F, Default)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec get_module_opt_host(global | binary(), atom(), binary()) -> binary().
|
||||||
|
|
||||||
get_module_opt_host(Host, Module, Default) ->
|
get_module_opt_host(Host, Module, Default) ->
|
||||||
Val = get_module_opt(Host, Module, host, Default),
|
Val = get_module_opt(Host, Module, host,
|
||||||
element(2, regexp:gsub(Val, "@HOST@", Host)).
|
fun iolist_to_binary/1,
|
||||||
|
Default),
|
||||||
|
ejabberd_regexp:greplace(Val, <<"@HOST@">>, Host).
|
||||||
|
|
||||||
|
-spec get_opt_host(binary(), opts(), binary()) -> binary().
|
||||||
|
|
||||||
get_opt_host(Host, Opts, Default) ->
|
get_opt_host(Host, Opts, Default) ->
|
||||||
Val = get_opt(host, Opts, Default),
|
Val = get_opt(host, Opts, fun iolist_to_binary/1, Default),
|
||||||
element(2, regexp:gsub(Val, "@HOST@", Host)).
|
ejabberd_regexp:greplace(Val, <<"@HOST@">>, Host).
|
||||||
|
|
||||||
|
-spec db_type(opts()) -> odbc | mnesia.
|
||||||
|
|
||||||
|
db_type(Opts) ->
|
||||||
|
get_opt(db_type, Opts,
|
||||||
|
fun(odbc) -> odbc;
|
||||||
|
(internal) -> mnesia;
|
||||||
|
(mnesia) -> mnesia end,
|
||||||
|
mnesia).
|
||||||
|
|
||||||
|
-spec db_type(binary(), atom()) -> odbc | mnesia.
|
||||||
|
|
||||||
|
db_type(Host, Module) ->
|
||||||
|
get_module_opt(Host, Module, db_type,
|
||||||
|
fun(odbc) -> odbc;
|
||||||
|
(internal) -> mnesia;
|
||||||
|
(mnesia) -> mnesia end,
|
||||||
|
mnesia).
|
||||||
|
|
||||||
|
-spec loaded_modules(binary()) -> [atom()].
|
||||||
|
|
||||||
loaded_modules(Host) ->
|
loaded_modules(Host) ->
|
||||||
ets:select(ejabberd_modules,
|
ets:select(ejabberd_modules,
|
||||||
[{#ejabberd_module{_ = '_', module_host = {'$1', Host}},
|
[{#ejabberd_module{_ = '_', module_host = {'$1', Host}},
|
||||||
[],
|
[], ['$1']}]).
|
||||||
['$1']}]).
|
|
||||||
|
-spec loaded_modules_with_opts(binary()) -> [{atom(), opts()}].
|
||||||
|
|
||||||
loaded_modules_with_opts(Host) ->
|
loaded_modules_with_opts(Host) ->
|
||||||
ets:select(ejabberd_modules,
|
ets:select(ejabberd_modules,
|
||||||
[{#ejabberd_module{_ = '_', module_host = {'$1', Host},
|
[{#ejabberd_module{_ = '_', module_host = {'$1', Host},
|
||||||
opts = '$2'},
|
opts = '$2'},
|
||||||
[],
|
[], [{{'$1', '$2'}}]}]).
|
||||||
[{{'$1', '$2'}}]}]).
|
|
||||||
|
|
||||||
set_module_opts_mnesia(Host, Module, Opts) ->
|
set_module_opts_mnesia(Host, Module, Opts) ->
|
||||||
Modules = case ejabberd_config:get_local_option({modules, Host}) of
|
Modules = ejabberd_config:get_local_option(
|
||||||
undefined ->
|
{modules, Host},
|
||||||
[];
|
fun(Ls) when is_list(Ls) -> Ls end,
|
||||||
Ls ->
|
[]),
|
||||||
Ls
|
|
||||||
end,
|
|
||||||
Modules1 = lists:keydelete(Module, 1, Modules),
|
Modules1 = lists:keydelete(Module, 1, Modules),
|
||||||
Modules2 = [{Module, Opts} | Modules1],
|
Modules2 = [{Module, Opts} | Modules1],
|
||||||
ejabberd_config:add_local_option({modules, Host}, Modules2).
|
ejabberd_config:add_local_option({modules, Host},
|
||||||
|
Modules2).
|
||||||
|
|
||||||
del_module_mnesia(Host, Module) ->
|
del_module_mnesia(Host, Module) ->
|
||||||
Modules = case ejabberd_config:get_local_option({modules, Host}) of
|
Modules = ejabberd_config:get_local_option(
|
||||||
undefined ->
|
{modules, Host},
|
||||||
[];
|
fun(Ls) when is_list(Ls) -> Ls end,
|
||||||
Ls ->
|
[]),
|
||||||
Ls
|
|
||||||
end,
|
|
||||||
Modules1 = lists:keydelete(Module, 1, Modules),
|
Modules1 = lists:keydelete(Module, 1, Modules),
|
||||||
ejabberd_config:add_local_option({modules, Host}, Modules1).
|
ejabberd_config:add_local_option({modules, Host},
|
||||||
|
Modules1).
|
||||||
|
|
||||||
|
-spec get_hosts(opts(), binary()) -> [binary()].
|
||||||
|
|
||||||
get_hosts(Opts, Prefix) ->
|
get_hosts(Opts, Prefix) ->
|
||||||
case catch gen_mod:get_opt(hosts, Opts) of
|
case get_opt(hosts, Opts,
|
||||||
{'EXIT', _Error1} ->
|
fun(Hs) -> [iolist_to_binary(H) || H <- Hs] end) of
|
||||||
case catch gen_mod:get_opt(host, Opts) of
|
undefined ->
|
||||||
{'EXIT', _Error2} ->
|
case get_opt(host, Opts,
|
||||||
[Prefix ++ Host || Host <- ?MYHOSTS];
|
fun iolist_to_binary/1) of
|
||||||
|
undefined ->
|
||||||
|
[<<Prefix/binary, Host/binary>> || Host <- ?MYHOSTS];
|
||||||
Host ->
|
Host ->
|
||||||
[Host]
|
[Host]
|
||||||
end;
|
end;
|
||||||
|
@ -226,11 +267,16 @@ get_hosts(Opts, Prefix) ->
|
||||||
Hosts
|
Hosts
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-spec get_module_proc(binary(), {frontend, atom()} | atom()) -> atom().
|
||||||
|
|
||||||
get_module_proc(Host, {frontend, Base}) ->
|
get_module_proc(Host, {frontend, Base}) ->
|
||||||
get_module_proc("frontend_" ++ Host, Base);
|
get_module_proc(<<"frontend_", Host/binary>>, Base);
|
||||||
get_module_proc(Host, Base) ->
|
get_module_proc(Host, Base) ->
|
||||||
list_to_atom(atom_to_list(Base) ++ "_" ++ Host).
|
binary_to_atom(
|
||||||
|
<<(erlang:atom_to_binary(Base, latin1))/binary, "_", Host/binary>>,
|
||||||
|
latin1).
|
||||||
|
|
||||||
|
-spec is_loaded(binary(), atom()) -> boolean().
|
||||||
|
|
||||||
is_loaded(Host, Module) ->
|
is_loaded(Host, Module) ->
|
||||||
ets:member(ejabberd_modules, {Module, Host}).
|
ets:member(ejabberd_modules, {Module, Host}).
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue