diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2013-04-08 11:12:54 +0200 |
---|---|---|
committer | Christophe Romain <christophe.romain@process-one.net> | 2013-06-13 11:11:02 +0200 |
commit | 4d8f7706240a1603468968f47fc7b150b788d62f (patch) | |
tree | 92d55d789cc7ac979b3c9e161ffb7f908eba043a /include | |
parent | Fix Guide: ejabberd_service expects a shaper_rule, not a shaper (diff) |
Switch to rebar build tool
Use dynamic Rebar configuration
Make iconv dependency optional
Disable transient_supervisors compile option
Add hipe compilation support
Only compile ibrowse and lhttpc when needed
Make it possible to generate an OTP application release
Add --enable-debug compile option
Add --enable-all compiler option
Add --enable-tools configure option
Add --with-erlang configure option.
Add --enable-erlang-version-check configure option.
Add lager support
Improve the test suite
Diffstat (limited to 'include')
-rw-r--r-- | include/adhoc.hrl | 45 | ||||
-rw-r--r-- | include/ejabberd.hrl | 52 | ||||
-rw-r--r-- | include/ejabberd_commands.hrl | 75 | ||||
-rw-r--r-- | include/ejabberd_config.hrl | 34 | ||||
-rw-r--r-- | include/ejabberd_ctl.hrl | 28 | ||||
-rw-r--r-- | include/ejabberd_http.hrl | 36 | ||||
-rw-r--r-- | include/ejabberd_web_admin.hrl | 105 | ||||
-rw-r--r-- | include/eldap.hrl | 64 | ||||
-rw-r--r-- | include/http_bind.hrl | 47 | ||||
-rw-r--r-- | include/jlib.hrl | 502 | ||||
-rw-r--r-- | include/logger.hrl | 57 | ||||
-rw-r--r-- | include/mod_muc_room.hrl | 116 | ||||
-rw-r--r-- | include/mod_privacy.hrl | 44 | ||||
-rw-r--r-- | include/mod_proxy65.hrl | 74 | ||||
-rw-r--r-- | include/mod_roster.hrl | 42 | ||||
-rw-r--r-- | include/ns.hrl | 146 | ||||
-rw-r--r-- | include/pubsub.hrl | 257 |
17 files changed, 1724 insertions, 0 deletions
diff --git a/include/adhoc.hrl b/include/adhoc.hrl new file mode 100644 index 00000000..0910dc62 --- /dev/null +++ b/include/adhoc.hrl @@ -0,0 +1,45 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +-record(adhoc_request, +{ + lang = <<"">> :: binary(), + node = <<"">> :: binary(), + sessionid = <<"">> :: binary(), + action = <<"">> :: binary(), + xdata = false :: false | xmlel(), + others = [] :: [xmlel()] +}). + +-record(adhoc_response, +{ + lang = <<"">> :: binary(), + node = <<"">> :: binary(), + sessionid = <<"">> :: binary(), + status :: atom(), + defaultaction = <<"">> :: binary(), + actions = [] :: [binary()], + notes = [] :: [{binary(), binary()}], + elements = [] :: [xmlel()] +}). + +-type adhoc_request() :: #adhoc_request{}. +-type adhoc_response() :: #adhoc_response{}. diff --git a/include/ejabberd.hrl b/include/ejabberd.hrl new file mode 100644 index 00000000..736a2aa4 --- /dev/null +++ b/include/ejabberd.hrl @@ -0,0 +1,52 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +%% 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 +-define(VERSION, ejabberd_config:get_version()). + +-define(MYHOSTS, ejabberd_config:get_myhosts()). + +-define(MYNAME, hd(ejabberd_config:get_myhosts())). + +-define(MYLANG, ejabberd_config:get_mylang()). + +-define(MSGS_DIR, filename:join(["priv", "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(DBGFSM, true). + +-record(scram, + {storedkey = <<"">>, + serverkey = <<"">>, + salt = <<"">>, + iterationcount = 0 :: integer()}). + +-type scram() :: #scram{}. + +-define(SCRAM_DEFAULT_ITERATION_COUNT, 4096). diff --git a/include/ejabberd_commands.hrl b/include/ejabberd_commands.hrl new file mode 100644 index 00000000..116bb735 --- /dev/null +++ b/include/ejabberd_commands.hrl @@ -0,0 +1,75 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +-type aterm() :: {atom(), atype()}. +-type atype() :: integer | string | binary | + {tuple, [aterm()]} | {list, aterm()}. +-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{ +%% name = atom(), +%% tags = [atom()], +%% desc = string(), +%% longdesc = string(), +%% module = atom(), +%% function = atom(), +%% args = [aterm()], +%% result = rterm() +%% }. +%% desc: Description of the command +%% args: Describe the accepted arguments. +%% This way the function that calls the command can format the +%% arguments before calling. + +%% @type atype() = integer | string | {tuple, [aterm()]} | {list, aterm()}. +%% Allowed types for arguments are integer, string, tuple and list. + +%% @type rtype() = integer | string | atom | {tuple, [rterm()]} | {list, rterm()} | rescode | restuple. +%% A rtype is either an atom or a tuple with two elements. + +%% @type aterm() = {Name::atom(), Type::atype()}. +%% An argument term is a tuple with the term name and the term type. + +%% @type rterm() = {Name::atom(), Type::rtype()}. +%% A result term is a tuple with the term name and the term type. + diff --git a/include/ejabberd_config.hrl b/include/ejabberd_config.hrl new file mode 100644 index 00000000..bf749dd1 --- /dev/null +++ b/include/ejabberd_config.hrl @@ -0,0 +1,34 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +-record(config, {key :: any(), value :: any()}). + +-record(local_config, {key :: any(), value :: any()}). + +-type config() :: #config{}. +-type local_config() :: #local_config{}. + +-record(state, + {opts = [] :: [acl:acl() | config() | local_config()], + hosts = [] :: [binary()], + override_local = false :: boolean(), + override_global = false :: boolean(), + override_acls = false :: boolean()}). diff --git a/include/ejabberd_ctl.hrl b/include/ejabberd_ctl.hrl new file mode 100644 index 00000000..09a5287e --- /dev/null +++ b/include/ejabberd_ctl.hrl @@ -0,0 +1,28 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +-define(STATUS_SUCCESS, 0). + +-define(STATUS_ERROR, 1). + +-define(STATUS_USAGE, 2). + +-define(STATUS_BADRPC, 3). diff --git a/include/ejabberd_http.hrl b/include/ejabberd_http.hrl new file mode 100644 index 00000000..542dc0cd --- /dev/null +++ b/include/ejabberd_http.hrl @@ -0,0 +1,36 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +-record(request, + {method, % :: method(), + path = [] :: [binary()], + q = [] :: [{binary() | nokey, binary()}], + us = {<<>>, <<>>} :: {binary(), binary()}, + auth :: {binary(), binary()} | + {auth_jid, {binary(), binary()}, jlib:jid()}, + lang = <<"">> :: binary(), + data = <<"">> :: binary(), + ip :: {inet:ip_address(), inet:port_number()}, + host = <<"">> :: binary(), + port = 5280 :: inet:port_number(), + tp = http, % :: protocol(), + headers = [] :: [{atom() | binary(), binary()}]}). + diff --git a/include/ejabberd_web_admin.hrl b/include/ejabberd_web_admin.hrl new file mode 100644 index 00000000..6c939f9e --- /dev/null +++ b/include/ejabberd_web_admin.hrl @@ -0,0 +1,105 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +-define(X(Name), + #xmlel{name = Name, attrs = [], children = []}). + +-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(XC(Name, Text), ?XE(Name, [?C(Text)])). + +-define(XAC(Name, Attrs, Text), + ?XAE(Name, Attrs, [?C(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(A(URL, Els), + ?XAE(<<"a">>, [{<<"href">>, URL}], Els)). + +-define(AC(URL, Text), ?A(URL, [?C(Text)])). + +-define(ACT(URL, Text), ?AC(URL, (?T(Text)))). + +-define(P, ?X(<<"p">>)). + +-define(BR, ?X(<<"br">>)). + +-define(INPUT(Type, Name, Value), + ?XA(<<"input">>, + [{<<"type">>, Type}, {<<"name">>, Name}, + {<<"value">>, Value}])). + +-define(INPUTT(Type, Name, Value), + ?INPUT(Type, Name, (?T(Value)))). + +-define(INPUTS(Type, Name, Value, Size), + ?XA(<<"input">>, + [{<<"type">>, Type}, {<<"name">>, Name}, + {<<"value">>, Value}, {<<"size">>, Size}])). + +-define(INPUTST(Type, Name, Value, Size), + ?INPUT(Type, Name, (?T(Value)), Size)). + +-define(ACLINPUT(Text), + ?XE(<<"td">>, + [?INPUT(<<"text">>, <<"value", ID/binary>>, Text)])). + +-define(TEXTAREA(Name, Rows, Cols, Value), + ?XAC(<<"textarea">>, + [{<<"name">>, Name}, {<<"rows">>, Rows}, + {<<"cols">>, Cols}], + Value)). + +%% Build an xmlelement for result +-define(XRES(Text), + ?XAC(<<"p">>, [{<<"class">>, <<"result">>}], Text)). + +%% Guide Link +-define(XREST(Text), ?XRES((?T(Text)))). + +-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 +-define(H1GL(Name, Ref, Title), + [?XC(<<"h1">>, Name), ?GL(Ref, Title)]). diff --git a/include/eldap.hrl b/include/eldap.hrl new file mode 100644 index 00000000..30ec0e95 --- /dev/null +++ b/include/eldap.hrl @@ -0,0 +1,64 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +-define(LDAP_PORT, 389). + +-define(LDAPS_PORT, 636). + +-type scope() :: baseObject | singleLevel | wholeSubtree. + +-record(eldap_search, + {scope = wholeSubtree :: scope(), + base = <<"">> :: binary(), + filter :: eldap:filter(), + limit = 0 :: non_neg_integer(), + attributes = [] :: [binary()], + types_only = false :: boolean(), + deref_aliases = neverDerefAliases :: neverDerefAliases | + derefInSearching | + derefFindingBaseObj | + derefAlways, + timeout = 0 :: non_neg_integer()}). + +-record(eldap_search_result, {entries = [] :: [eldap_entry()], + referrals = [] :: list()}). + +-record(eldap_entry, {object_name = <<>> :: binary(), + attributes = [] :: [{binary(), [binary()]}]}). + +-type tlsopts() :: [{encrypt, tls | starttls | none} | + {tls_cacertfile, binary() | undefined} | + {tls_depth, non_neg_integer() | undefined} | + {tls_verify, hard | soft | false}]. + +-record(eldap_config, {servers = [] :: [binary()], + backups = [] :: [binary()], + tls_options = [] :: tlsopts(), + port = ?LDAP_PORT :: inet:port_number(), + dn = <<"">> :: binary(), + password = <<"">> :: binary(), + base = <<"">> :: binary(), + deref_aliases = never :: never | searching | + finding | always}). + +-type eldap_config() :: #eldap_config{}. +-type eldap_search() :: #eldap_search{}. +-type eldap_entry() :: #eldap_entry{}. diff --git a/include/http_bind.hrl b/include/http_bind.hrl new file mode 100644 index 00000000..2eac91e9 --- /dev/null +++ b/include/http_bind.hrl @@ -0,0 +1,47 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +-define(CT_XML, + {<<"Content-Type">>, <<"text/xml; charset=utf-8">>}). + +-define(CT_PLAIN, + {<<"Content-Type">>, <<"text/plain">>}). + +-define(AC_ALLOW_ORIGIN, + {<<"Access-Control-Allow-Origin">>, <<"*">>}). + +-define(AC_ALLOW_METHODS, + {<<"Access-Control-Allow-Methods">>, + <<"GET, POST, OPTIONS">>}). + +-define(AC_ALLOW_HEADERS, + {<<"Access-Control-Allow-Headers">>, + <<"Content-Type">>}). + +-define(AC_MAX_AGE, + {<<"Access-Control-Max-Age">>, <<"86400">>}). + +-define(OPTIONS_HEADER, + [?CT_PLAIN, ?AC_ALLOW_ORIGIN, ?AC_ALLOW_METHODS, + ?AC_ALLOW_HEADERS, ?AC_MAX_AGE]). + +-define(HEADER, + [?CT_XML, ?AC_ALLOW_ORIGIN, ?AC_ALLOW_HEADERS]). diff --git a/include/jlib.hrl b/include/jlib.hrl new file mode 100644 index 00000000..13fb8fcf --- /dev/null +++ b/include/jlib.hrl @@ -0,0 +1,502 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +-include("ns.hrl"). +-include("xml.hrl"). + +-define(STANZA_ERROR(Code, Type, Condition), + #xmlel{name = <<"error">>, + attrs = [{<<"code">>, Code}, {<<"type">>, Type}], + children = + [#xmlel{name = Condition, + attrs = [{<<"xmlns">>, ?NS_STANZAS}], + children = []}]}). + +-define(ERR_BAD_FORMAT, + ?STANZA_ERROR(<<"406">>, <<"modify">>, + <<"bad-format">>)). + +-define(ERR_BAD_REQUEST, + ?STANZA_ERROR(<<"400">>, <<"modify">>, + <<"bad-request">>)). + +-define(ERR_CONFLICT, + ?STANZA_ERROR(<<"409">>, <<"cancel">>, <<"conflict">>)). + +-define(ERR_FEATURE_NOT_IMPLEMENTED, + ?STANZA_ERROR(<<"501">>, <<"cancel">>, + <<"feature-not-implemented">>)). + +-define(ERR_FORBIDDEN, + ?STANZA_ERROR(<<"403">>, <<"auth">>, <<"forbidden">>)). + +-define(ERR_GONE, + ?STANZA_ERROR(<<"302">>, <<"modify">>, <<"gone">>)). + +-define(ERR_INTERNAL_SERVER_ERROR, + ?STANZA_ERROR(<<"500">>, <<"wait">>, + <<"internal-server-error">>)). + +-define(ERR_ITEM_NOT_FOUND, + ?STANZA_ERROR(<<"404">>, <<"cancel">>, + <<"item-not-found">>)). + +-define(ERR_JID_MALFORMED, + ?STANZA_ERROR(<<"400">>, <<"modify">>, + <<"jid-malformed">>)). + +-define(ERR_NOT_ACCEPTABLE, + ?STANZA_ERROR(<<"406">>, <<"modify">>, + <<"not-acceptable">>)). + +-define(ERR_NOT_ALLOWED, + ?STANZA_ERROR(<<"405">>, <<"cancel">>, + <<"not-allowed">>)). + +-define(ERR_NOT_AUTHORIZED, + ?STANZA_ERROR(<<"401">>, <<"auth">>, + <<"not-authorized">>)). + +-define(ERR_PAYMENT_REQUIRED, + ?STANZA_ERROR(<<"402">>, <<"auth">>, + <<"payment-required">>)). + +-define(ERR_RECIPIENT_UNAVAILABLE, + ?STANZA_ERROR(<<"404">>, <<"wait">>, + <<"recipient-unavailable">>)). + +-define(ERR_REDIRECT, + ?STANZA_ERROR(<<"302">>, <<"modify">>, <<"redirect">>)). + +-define(ERR_REGISTRATION_REQUIRED, + ?STANZA_ERROR(<<"407">>, <<"auth">>, + <<"registration-required">>)). + +-define(ERR_REMOTE_SERVER_NOT_FOUND, + ?STANZA_ERROR(<<"404">>, <<"cancel">>, + <<"remote-server-not-found">>)). + +-define(ERR_REMOTE_SERVER_TIMEOUT, + ?STANZA_ERROR(<<"504">>, <<"wait">>, + <<"remote-server-timeout">>)). + +-define(ERR_RESOURCE_CONSTRAINT, + ?STANZA_ERROR(<<"500">>, <<"wait">>, + <<"resource-constraint">>)). + +-define(ERR_SERVICE_UNAVAILABLE, + ?STANZA_ERROR(<<"503">>, <<"cancel">>, + <<"service-unavailable">>)). + +-define(ERR_SUBSCRIPTION_REQUIRED, + ?STANZA_ERROR(<<"407">>, <<"auth">>, + <<"subscription-required">>)). + +-define(ERR_UNEXPECTED_REQUEST, + ?STANZA_ERROR(<<"400">>, <<"wait">>, + <<"unexpected-request">>)). + +-define(ERR_UNEXPECTED_REQUEST_CANCEL, + ?STANZA_ERROR(<<"401">>, <<"cancel">>, + <<"unexpected-request">>)). + +%-define(ERR_, +% ?STANZA_ERROR("", "", "")). + +-define(STANZA_ERRORT(Code, Type, Condition, Lang, + Text), + #xmlel{name = <<"error">>, + attrs = [{<<"code">>, Code}, {<<"type">>, Type}], + children = + [#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), + ?STANZA_ERRORT(<<"406">>, <<"modify">>, + <<"bad-format">>, Lang, Text)). + +-define(ERRT_BAD_REQUEST(Lang, Text), + ?STANZA_ERRORT(<<"400">>, <<"modify">>, + <<"bad-request">>, Lang, Text)). + +-define(ERRT_CONFLICT(Lang, Text), + ?STANZA_ERRORT(<<"409">>, <<"cancel">>, <<"conflict">>, + Lang, Text)). + +-define(ERRT_FEATURE_NOT_IMPLEMENTED(Lang, Text), + ?STANZA_ERRORT(<<"501">>, <<"cancel">>, + <<"feature-not-implemented">>, Lang, Text)). + +-define(ERRT_FORBIDDEN(Lang, Text), + ?STANZA_ERRORT(<<"403">>, <<"auth">>, <<"forbidden">>, + Lang, Text)). + +-define(ERRT_GONE(Lang, Text), + ?STANZA_ERRORT(<<"302">>, <<"modify">>, <<"gone">>, + Lang, Text)). + +-define(ERRT_INTERNAL_SERVER_ERROR(Lang, Text), + ?STANZA_ERRORT(<<"500">>, <<"wait">>, + <<"internal-server-error">>, Lang, Text)). + +-define(ERRT_ITEM_NOT_FOUND(Lang, Text), + ?STANZA_ERRORT(<<"404">>, <<"cancel">>, + <<"item-not-found">>, Lang, Text)). + +-define(ERRT_JID_MALFORMED(Lang, Text), + ?STANZA_ERRORT(<<"400">>, <<"modify">>, + <<"jid-malformed">>, Lang, Text)). + +-define(ERRT_NOT_ACCEPTABLE(Lang, Text), + ?STANZA_ERRORT(<<"406">>, <<"modify">>, + <<"not-acceptable">>, Lang, Text)). + +-define(ERRT_NOT_ALLOWED(Lang, Text), + ?STANZA_ERRORT(<<"405">>, <<"cancel">>, + <<"not-allowed">>, Lang, Text)). + +-define(ERRT_NOT_AUTHORIZED(Lang, Text), + ?STANZA_ERRORT(<<"401">>, <<"auth">>, + <<"not-authorized">>, Lang, Text)). + +-define(ERRT_PAYMENT_REQUIRED(Lang, Text), + ?STANZA_ERRORT(<<"402">>, <<"auth">>, + <<"payment-required">>, Lang, Text)). + +-define(ERRT_RECIPIENT_UNAVAILABLE(Lang, Text), + ?STANZA_ERRORT(<<"404">>, <<"wait">>, + <<"recipient-unavailable">>, Lang, Text)). + +-define(ERRT_REDIRECT(Lang, Text), + ?STANZA_ERRORT(<<"302">>, <<"modify">>, <<"redirect">>, + Lang, Text)). + +-define(ERRT_REGISTRATION_REQUIRED(Lang, Text), + ?STANZA_ERRORT(<<"407">>, <<"auth">>, + <<"registration-required">>, Lang, Text)). + +-define(ERRT_REMOTE_SERVER_NOT_FOUND(Lang, Text), + ?STANZA_ERRORT(<<"404">>, <<"cancel">>, + <<"remote-server-not-found">>, Lang, Text)). + +-define(ERRT_REMOTE_SERVER_TIMEOUT(Lang, Text), + ?STANZA_ERRORT(<<"504">>, <<"wait">>, + <<"remote-server-timeout">>, Lang, Text)). + +-define(ERRT_RESOURCE_CONSTRAINT(Lang, Text), + ?STANZA_ERRORT(<<"500">>, <<"wait">>, + <<"resource-constraint">>, Lang, Text)). + +-define(ERRT_SERVICE_UNAVAILABLE(Lang, Text), + ?STANZA_ERRORT(<<"503">>, <<"cancel">>, + <<"service-unavailable">>, Lang, Text)). + +-define(ERRT_SUBSCRIPTION_REQUIRED(Lang, Text), + ?STANZA_ERRORT(<<"407">>, <<"auth">>, + <<"subscription-required">>, Lang, Text)). + +-define(ERRT_UNEXPECTED_REQUEST(Lang, Text), + ?STANZA_ERRORT(<<"400">>, <<"wait">>, + <<"unexpected-request">>, Lang, Text)). + +-define(ERR_AUTH_NO_RESOURCE_PROVIDED(Lang), + ?ERRT_NOT_ACCEPTABLE(Lang, <<"No resource provided">>)). + +-define(ERR_AUTH_BAD_RESOURCE_FORMAT(Lang), + ?ERRT_NOT_ACCEPTABLE(Lang, + <<"Illegal resource format">>)). + +-define(ERR_AUTH_RESOURCE_CONFLICT(Lang), + ?ERRT_CONFLICT(Lang, <<"Resource conflict">>)). + +-define(STREAM_ERROR(Condition, Cdata), + #xmlel{name = <<"stream:error">>, attrs = [], + children = + [#xmlel{name = Condition, + attrs = [{<<"xmlns">>, ?NS_STREAMS}], + children = [{xmlcdata, Cdata}]}]}). + +-define(SERR_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">>, <<"">>)). + +-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), + ?STREAM_ERRORT(<<"bad-format">>, <<"">>, Lang, Text)). + +-define(SERRT_BAD_NAMESPACE_PREFIX(Lang, Text), + ?STREAM_ERRORT(<<"bad-namespace-prefix">>, <<"">>, Lang, + Text)). + +-define(SERRT_CONFLICT(Lang, Text), + ?STREAM_ERRORT(<<"conflict">>, <<"">>, Lang, Text)). + +-define(SERRT_CONNECTION_TIMEOUT(Lang, Text), + ?STREAM_ERRORT(<<"connection-timeout">>, <<"">>, Lang, + Text)). + +-define(SERRT_HOST_GONE(Lang, Text), + ?STREAM_ERRORT(<<"host-gone">>, <<"">>, Lang, Text)). + +-define(SERRT_HOST_UNKNOWN(Lang, Text), + ?STREAM_ERRORT(<<"host-unknown">>, <<"">>, Lang, Text)). + +-define(SERRT_IMPROPER_ADDRESSING(Lang, Text), + ?STREAM_ERRORT(<<"improper-addressing">>, <<"">>, Lang, + Text)). + +-define(SERRT_INTERNAL_SERVER_ERROR(Lang, Text), + ?STREAM_ERRORT(<<"internal-server-error">>, <<"">>, + Lang, Text)). + +-define(SERRT_INVALID_FROM(Lang, Text), + ?STREAM_ERRORT(<<"invalid-from">>, <<"">>, Lang, Text)). + +-define(SERRT_INVALID_ID(Lang, Text), + ?STREAM_ERRORT(<<"invalid-id">>, <<"">>, Lang, Text)). + +-define(SERRT_INVALID_NAMESPACE(Lang, Text), + ?STREAM_ERRORT(<<"invalid-namespace">>, <<"">>, Lang, + Text)). + +-define(SERRT_INVALID_XML(Lang, Text), + ?STREAM_ERRORT(<<"invalid-xml">>, <<"">>, Lang, Text)). + +-define(SERRT_NOT_AUTHORIZED(Lang, Text), + ?STREAM_ERRORT(<<"not-authorized">>, <<"">>, Lang, + Text)). + +-define(SERRT_POLICY_VIOLATION(Lang, Text), + ?STREAM_ERRORT(<<"policy-violation">>, <<"">>, Lang, + Text)). + +-define(SERRT_REMOTE_CONNECTION_FAILED(Lang, Text), + ?STREAM_ERRORT(<<"remote-connection-failed">>, <<"">>, + Lang, Text)). + +-define(SERRT_RESOURSE_CONSTRAINT(Lang, Text), + ?STREAM_ERRORT(<<"resource-constraint">>, <<"">>, Lang, + Text)). + +-define(SERRT_RESTRICTED_XML(Lang, Text), + ?STREAM_ERRORT(<<"restricted-xml">>, <<"">>, Lang, + Text)). + +-define(SERRT_SEE_OTHER_HOST(Host, Lang, Text), + ?STREAM_ERRORT(<<"see-other-host">>, Host, Lang, Text)). + +-define(SERRT_SYSTEM_SHUTDOWN(Lang, Text), + ?STREAM_ERRORT(<<"system-shutdown">>, <<"">>, Lang, + Text)). + +-define(SERRT_UNSUPPORTED_ENCODING(Lang, Text), + ?STREAM_ERRORT(<<"unsupported-encoding">>, <<"">>, Lang, + Text)). + +-define(SERRT_UNSUPPORTED_STANZA_TYPE(Lang, Text), + ?STREAM_ERRORT(<<"unsupported-stanza-type">>, <<"">>, + Lang, Text)). + +-define(SERRT_UNSUPPORTED_VERSION(Lang, Text), + ?STREAM_ERRORT(<<"unsupported-version">>, <<"">>, Lang, + Text)). + +-define(SERRT_XML_NOT_WELL_FORMED(Lang, Text), + ?STREAM_ERRORT(<<"xml-not-well-formed">>, <<"">>, Lang, + Text)). + +-record(jid, {user = <<"">> :: binary(), + server = <<"">> :: binary(), + resource = <<"">> :: binary(), + luser = <<"">> :: binary(), + lserver = <<"">> :: binary(), + lresource = <<"">> :: binary()}). + +-type(jid() :: #jid{}). + +-type(ljid() :: {binary(), binary(), binary()}). + +-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{}. diff --git a/include/logger.hrl b/include/logger.hrl new file mode 100644 index 00000000..32e2348c --- /dev/null +++ b/include/logger.hrl @@ -0,0 +1,57 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- +-define(PRINT(Format, Args), io:format(Format, Args)). + +-ifdef(LAGER). +-compile([{parse_transform, lager_transform}]). + +-define(DEBUG(Format, Args), + lager:debug(Format, Args)). + +-define(INFO_MSG(Format, Args), + lager:info(Format, Args)). + +-define(WARNING_MSG(Format, Args), + lager:warning(Format, Args)). + +-define(ERROR_MSG(Format, Args), + lager:error(Format, Args)). + +-define(CRITICAL_MSG(Format, Args), + lager:critical(Format, Args)). + +-else. + +-define(DEBUG(Format, Args), + ejabberd_logger:debug_msg(?MODULE, ?LINE, Format, Args)). + +-define(INFO_MSG(Format, Args), + ejabberd_logger:info_msg(?MODULE, ?LINE, Format, Args)). + +-define(WARNING_MSG(Format, Args), + ejabberd_logger:warning_msg(?MODULE, ?LINE, Format, Args)). + +-define(ERROR_MSG(Format, Args), + ejabberd_logger:error_msg(?MODULE, ?LINE, Format, Args)). + +-define(CRITICAL_MSG(Format, Args), + ejabberd_logger:critical_msg(?MODULE, ?LINE, Format, Args)). +-endif. diff --git a/include/mod_muc_room.hrl b/include/mod_muc_room.hrl new file mode 100644 index 00000000..3bbc9318 --- /dev/null +++ b/include/mod_muc_room.hrl @@ -0,0 +1,116 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +-define(MAX_USERS_DEFAULT, 200). + +-define(SETS, gb_sets). + +-define(DICT, dict). + +-record(lqueue, +{ + queue :: queue(), + len :: integer(), + max :: integer() +}). + +-type lqueue() :: #lqueue{}. + +-record(config, +{ + title = <<"">> :: binary(), + 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() +}). + +-type config() :: #config{}. + +-type role() :: moderator | participant | visitor | none. + +-record(user, +{ + jid :: jid(), + 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{}. diff --git a/include/mod_privacy.hrl b/include/mod_privacy.hrl new file mode 100644 index 00000000..f70982b0 --- /dev/null +++ b/include/mod_privacy.hrl @@ -0,0 +1,44 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +-record(privacy, {us = {<<"">>, <<"">>} :: {binary(), binary()}, + default = none :: none | binary(), + lists = [] :: [{binary(), [listitem()]}]}). + +-record(listitem, {type = none :: none | jid | group | subscription, + value = none :: none | both | from | to | ljid() | binary(), + action = allow :: allow | deny, + order = 0 :: integer(), + match_all = false :: boolean(), + match_iq = false :: boolean(), + match_message = false :: boolean(), + match_presence_in = false :: boolean(), + match_presence_out = false :: boolean()}). + +-type listitem() :: #listitem{}. + +-record(userlist, {name = none :: none | binary(), + list = [] :: [listitem()], + needdb = false :: boolean()}). + +-type userlist() :: #userlist{}. + +-export_type([userlist/0]). diff --git a/include/mod_proxy65.hrl b/include/mod_proxy65.hrl new file mode 100644 index 00000000..d0779af1 --- /dev/null +++ b/include/mod_proxy65.hrl @@ -0,0 +1,74 @@ +%%%---------------------------------------------------------------------- +%%% RFC 1928 constants. +%%% +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +%% Version +-define(VERSION_5, 5). + +%% Authentication methods +-define(AUTH_ANONYMOUS, 0). + +-define(AUTH_GSSAPI, 1). + +-define(AUTH_PLAIN, 2). + +%% Address Type +-define(AUTH_NO_METHODS, 255). + +-define(ATYP_IPV4, 1). + +-define(ATYP_DOMAINNAME, 3). + +-define(ATYP_IPV6, 4). + +%% Commands +-define(CMD_CONNECT, 1). + +-define(CMD_BIND, 2). + +-define(CMD_UDP, 3). + +%% RFC 1928 replies +-define(SUCCESS, 0). + +-define(ERR_GENERAL_FAILURE, 1). + +-define(ERR_NOT_ALLOWED, 2). + +-define(ERR_NETWORK_UNREACHABLE, 3). + +-define(ERR_HOST_UNREACHABLE, 4). + +-define(ERR_CONNECTION_REFUSED, 5). + +-define(ERR_TTL_EXPIRED, 6). + +-define(ERR_COMMAND_NOT_SUPPORTED, 7). + +-define(ERR_ADDRESS_TYPE_NOT_SUPPORTED, 8). + +%% RFC 1928 defined timeout. +-define(SOCKS5_REPLY_TIMEOUT, 10000). + +-record(s5_request, {rsv = 0 :: integer(), + cmd = connect :: connect | udp, + sha1 = <<"">> :: binary()}). diff --git a/include/mod_roster.hrl b/include/mod_roster.hrl new file mode 100644 index 00000000..4751eec3 --- /dev/null +++ b/include/mod_roster.hrl @@ -0,0 +1,42 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +-record(roster, +{ + usj = {<<>>, <<>>, {<<>>, <<>>, <<>>}} :: {binary(), binary(), ljid()} | '_', + us = {<<>>, <<>>} :: {binary(), binary()} | '_', + jid = {<<>>, <<>>, <<>>} :: ljid(), + name = <<>> :: binary() | '_', + subscription = none :: subscription() | '_', + ask = none :: ask() | '_', + groups = [] :: [binary()] | '_', + askmessage = <<"">> :: binary() | '_', + xs = [] :: [xmlel()] | '_' +}). + +-record(roster_version, +{ + us = {<<>>, <<>>} :: {binary(), binary()}, + version = <<>> :: binary() +}). + +-type ask() :: none | in | out | both | subscribe | unsubscribe. +-type subscription() :: none | both | from | to | remove. diff --git a/include/ns.hrl b/include/ns.hrl new file mode 100644 index 00000000..6d041a47 --- /dev/null +++ b/include/ns.hrl @@ -0,0 +1,146 @@ +%%%---------------------------------------------------------------------- +%%% +%%% ejabberd, Copyright (C) 2002-2013 ProcessOne +%%% +%%% This program is free software; you can redistribute it and/or +%%% modify it under the terms of the GNU General Public License as +%%% published by the Free Software Foundation; either version 2 of the +%%% License, or (at your option) any later version. +%%% +%%% This program is distributed in the hope that it will be useful, +%%% but WITHOUT ANY WARRANTY; without even the implied warranty of +%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%%% General Public License for more details. +%%% +%%% You should have received a copy of the GNU General Public License +%%% along with this program; if not, write to the Free Software +%%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +%%% 02111-1307 USA +%%% +%%%---------------------------------------------------------------------- + +-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">>). +-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">>). +-define(NS_PING, <<"urn:xmpp:ping">>). diff --git a/include/pubsub.hrl b/include/pubsub.hrl new file mode 100644 index 00000000..4f2cc9f3 --- /dev/null +++ b/include/pubsub.hrl @@ -0,0 +1,257 @@ +%%% ==================================================================== +%%% ``The contents of this file are subject to the Erlang Public License, +%%% Version 1.1, (the "License"); you may not use this file except in +%%% compliance with the License. You should have received a copy of the +%%% Erlang Public License along with this software. If not, it can be +%%% retrieved via the world wide web at http://www.erlang.org/. +%%% +%%% +%%% Software distributed under the License is distributed on an "AS IS" +%%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See +%%% the License for the specific language governing rights and limitations +%%% under the License. +%%% +%%% +%%% The Initial Developer of the Original Code is ProcessOne. +%%% Portions created by ProcessOne are Copyright 2006-2013, ProcessOne +%%% All Rights Reserved.'' +%%% This software is copyright 2006-2013, ProcessOne. +%%% +%%% +%%% copyright 2006-2013 ProcessOne +%%% +%%% This file contains pubsub types definition. +%%% ==================================================================== + +%% ------------------------------- +%% Pubsub constants +-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 +-define(MAXITEMS, 10). + +%% this is currently a hard limit. +%% Would be nice to have it configurable. +-define(MAX_PAYLOAD_SIZE, 60000). + +%% ------------------------------- +%% Pubsub types + +%% @type hostPubsub() = string(). +-type(hostPubsub() :: binary()). +%% <p><tt>hostPubsub</tt> is the name of the PubSub service. For example, it can be +%% <tt>"pubsub.localhost"</tt>.</p> + +-type(hostPEP() :: {binary(), binary(), <<>>}). +%% @type hostPEP() = {User, Server, Resource} +%% User = string() +%% Server = string() +%% Resource = []. +%% <p>For example, it can be : +%% ```{"bob", "example.org", []}'''.</p> + +-type(host() :: hostPubsub() | hostPEP()). +%% @type host() = hostPubsub() | hostPEP(). + +-type(nodeId() :: binary()). +%% @type nodeId() = binary(). +%% <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: +%% ```<<"/home/localhost/user">>'''</p> + +-type(nodeIdx() :: pos_integer()). +%% @type nodeIdx() = integer(). + +-type(itemId() :: binary()). +%% @type itemId() = string(). + +-type(subId() :: binary()). +%% @type subId() = string(). + + +%% @type payload() = [#xmlelement{} | #xmlcdata{}]. + +%% @type stanzaError() = #xmlelement{}. +%% Example: +%% Example: +%% ```{xmlelement, "error", +%% [{"code", Code}, {"type", Type}], +%% [{xmlelement, Condition, [{"xmlns", ?NS_STANZAS}], []}]}''' +%% @type pubsubIQResponse() = #xmlelement{}. +%% Example: +%% ```{xmlelement, "pubsub", +%% [{"xmlns", ?NS_PUBSUB_EVENT}], +%% [{xmlelement, "affiliations", [], +%% []}]}''' + +-type(nodeOption() :: + {Option::atom(), + Value::binary() | [binary()] | boolean() | non_neg_integer() +}). + +-type(nodeOptions() :: [NodeOption::mod_pubsub:nodeOption(),...]). + +%% @type nodeOption() = {Option, Value} +%% Option = atom() +%% Value = term(). +%% Example: +%% ```{deliver_payloads, true}''' + +-type(subOption() :: + {Option::atom(), + Value::binary() | [binary()] | boolean() +}). + +-type(subOptions() :: [SubOption::mod_pubsub:subOption(),...]). + +%% @type nodeType() = string(). +%% <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 +%% <tt>"flat"</tt>, <tt>"hometree"</tt> or <tt>"blog"</tt>.</p> + +%% @type jid() = {jid, User, Server, Resource, LUser, LServer, LResource} +%% User = string() +%% Server = string() +%% Resource = string() +%% LUser = string() +%% LServer = string() +%% LResource = string(). + +%-type(ljid() :: {binary(), binary(), binary()}). +%% @type ljid() = {User, Server, Resource} +%% User = string() +%% Server = string() +%% Resource = string(). + +-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(accessModel() :: 'open' + | 'presence' + | 'roster' + | 'authorize' + | 'whitelist' +). +%% @type accessModel() = 'open' | 'presence' | 'roster' | 'authorize' | 'whitelist'. + +%% @type pubsubIndex() = {pubsub_index, Index, Last, Free} +%% Index = atom() +%% Last = integer() +%% Free = [integer()]. +%% internal pubsub index table +-type(publishModel() :: 'publishers' + | 'subscribers' + | 'open' +). + + +-record(pubsub_index, +{ + index :: atom(), + last :: mod_pubsub:nodeIdx(), + free :: [mod_pubsub:nodeIdx()] +}). + +%% @type pubsubNode() = {pubsub_node, NodeId, Id, Parents, Type, Owners, Options} +%% NodeId = {host() | ljid(), nodeId()} +%% Id = nodeIdx() +%% Parents = [nodeId()] +%% Type = nodeType() +%% Owners = [ljid()] +%% Options = [nodeOption()]. +%% <p>This is the format of the <tt>nodes</tt> table. The type of the table +%% is: <tt>set</tt>,<tt>ram/disc</tt>.</p> +%% <p>The <tt>Parents</tt> and <tt>type</tt> fields are indexed.</p> +%% <tt>id</tt> can be anything you want. +-record(pubsub_node, +{ + nodeid ,%:: {Host::mod_pubsub:host(), NodeId::mod_pubsub:nodeId()}, + id ,%:: mod_pubsub:nodeIdx(), + parents = [] ,%:: [Parent_NodeId::mod_pubsub:nodeId()], + type = <<"flat">> ,%:: binary(), + owners = [] ,%:: [Owner::ljid(),...], + options = [] %:: mod_pubsub:nodeOptions() +}). + +%% @type pubsubState() = {pubsub_state, StateId, Items, Affiliation, Subscriptions} +%% StateId = {ljid(), nodeIdx()} +%% Items = [itemId()] +%% Affiliation = affiliation() +%% Subscriptions = [{subscription(), subId()}]. +%% <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> + +%-record(pubsub_state, +% {stateid, items = [], affiliation = none, +% subscriptions = []}). +-record(pubsub_state, +{ + stateid ,%:: {Entity::ljid(), NodeIdx::mod_pubsub:nodeIdx()}, + items = [] ,%:: [ItemId::mod_pubsub:itemId()], + affiliation = 'none' ,%:: mod_pubsub:affiliation(), + subscriptions = [] %:: [{mod_pubsub:subscription(), mod_pubsub:subId()}] +}). + +%% @type pubsubItem() = {pubsub_item, ItemId, Creation, Modification, Payload} +%% ItemId = {itemId(), nodeIdx()} +%% Creation = {now(), ljid()} +%% Modification = {now(), ljid()} +%% Payload = payload(). +%% <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> +%-record(pubsub_item, +% {itemid, creation = {unknown, unknown}, +% modification = {unknown, unknown}, payload = []}). + +-record(pubsub_item, +{ + itemid ,%:: {mod_pubsub:itemId(), mod_pubsub:nodeIdx()}, + creation = {unknown, unknown} ,%:: {erlang:timestamp(), ljid()}, + modification = {unknown, unknown} ,%:: {erlang:timestamp(), ljid()}, + payload = [] %:: mod_pubsub:payload() +}). + +%% @type pubsubSubscription() = {pubsub_subscription, SubId, Options} +%% SubId = subId() +%% Options = [nodeOption()]. +%% <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> +%-record(pubsub_subscription, {subid, options}). +-record(pubsub_subscription, +{ + subid ,%:: mod_pubsub:subId(), + options %:: [] | mod_pubsub:subOptions() +}). + +%% @type pubsubLastItem() = {pubsub_last_item, NodeId, ItemId, Creation, Payload} +%% NodeId = nodeIdx() +%% ItemId = itemId() +%% Creation = {now(),ljid()} +%% Payload = payload(). +%% <p>This is the format of the <tt>last items</tt> table. it stores last item payload +%% for every node</p> +%-record(pubsub_last_item, +% {nodeid, itemid, creation, payload}). + +-record(pubsub_last_item, +{ + nodeid ,%:: mod_pubsub:nodeIdx(), + itemid ,%:: mod_pubsub:itemId(), + creation ,%:: {erlang:timestamp(), ljid()}, + payload %:: mod_pubsub:payload() +}). |