2007-12-01 06:16:30 +01:00
|
|
|
%%% ====================================================================
|
2007-12-24 14:57:53 +01:00
|
|
|
%%% ``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.
|
|
|
|
%%%
|
2008-09-16 16:39:57 +02:00
|
|
|
%%% The Initial Developer of the Original Code is ProcessOne.
|
2010-01-12 17:15:16 +01:00
|
|
|
%%% Portions created by ProcessOne are Copyright 2006-2010, ProcessOne
|
2007-12-24 14:57:53 +01:00
|
|
|
%%% All Rights Reserved.''
|
2010-01-12 17:15:16 +01:00
|
|
|
%%% This software is copyright 2006-2010, ProcessOne.
|
2007-12-24 14:57:53 +01:00
|
|
|
%%%
|
|
|
|
%%%
|
2010-01-12 17:15:16 +01:00
|
|
|
%%% copyright 2006-2010 ProcessOne
|
2007-12-01 06:16:30 +01:00
|
|
|
%%%
|
|
|
|
%%% This file contains pubsub types definition.
|
|
|
|
%%% ====================================================================
|
|
|
|
|
|
|
|
%% -------------------------------
|
|
|
|
%% Pubsub constants
|
|
|
|
-define(ERR_EXTENDED(E,C), mod_pubsub:extended_error(E,C)).
|
|
|
|
|
2009-09-23 18:32:06 +02:00
|
|
|
%% The actual limit can be configured with mod_pubsub's option max_items_node
|
|
|
|
-define(MAXITEMS, 10).
|
|
|
|
|
2007-12-01 06:16:30 +01:00
|
|
|
%% this is currently a hard limit.
|
|
|
|
%% Would be nice to have it configurable.
|
|
|
|
-define(MAX_PAYLOAD_SIZE, 60000).
|
|
|
|
|
|
|
|
%% -------------------------------
|
|
|
|
%% Pubsub types
|
|
|
|
|
|
|
|
%%% @type host() = string().
|
|
|
|
%%% <p><tt>host</tt> is the name of the PubSub service. For example, it can be
|
|
|
|
%%% <tt>"pubsub.localhost"</tt>.</p>
|
|
|
|
|
|
|
|
%%% @type pubsubNode() = [string()].
|
|
|
|
%%% <p>A node is defined by a list of its ancestors. The last element is the name
|
|
|
|
%%% of the current node. For example:
|
|
|
|
%%% ```["home", "localhost", "cromain", "node1"]'''</p>
|
|
|
|
|
2010-01-27 19:53:56 +01:00
|
|
|
%%% @type stanzaError() = #xmlel{}.
|
2007-12-01 06:16:30 +01:00
|
|
|
%%% Example:
|
2010-01-27 19:53:56 +01:00
|
|
|
%%% ```#xmlel{name = 'error'
|
|
|
|
%%% ns = ?NS_STANZAS,
|
|
|
|
%%% attrs = [
|
|
|
|
%%% #xmlattr{
|
|
|
|
%%% name = 'code',
|
|
|
|
%%% ns = ?NS_STANZAS,
|
|
|
|
%%% value = Code
|
|
|
|
%%% },
|
|
|
|
%%% attrs = [
|
|
|
|
%%% #xmlattr{
|
|
|
|
%%% name = 'type',
|
|
|
|
%%% ns = ?NS_STANZAS,
|
|
|
|
%%% value = Type
|
|
|
|
%%% }
|
|
|
|
%%% ]}'''
|
2007-12-01 06:16:30 +01:00
|
|
|
|
2010-01-27 19:53:56 +01:00
|
|
|
%%% @type pubsubIQResponse() = #xmlel{}.
|
2007-12-01 06:16:30 +01:00
|
|
|
%%% Example:
|
2010-01-27 19:53:56 +01:00
|
|
|
%%% ```#xmlel{name = 'pubsub',
|
|
|
|
%%% ns = ?NS_PUBSUB,
|
|
|
|
%%% children = [
|
|
|
|
%%% #xmlel{name = 'affiliations'
|
|
|
|
%%% ns = ?NS_PUBSUB
|
|
|
|
%%% }
|
|
|
|
%%% ]
|
|
|
|
%%% }'''
|
2007-12-01 06:16:30 +01:00
|
|
|
|
|
|
|
%%% @type nodeOption() = {Option::atom(), Value::term()}.
|
|
|
|
%%% Example:
|
|
|
|
%%% ```{deliver_payloads, true}'''
|
|
|
|
|
|
|
|
%%% @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
|
2009-05-29 02:27:26 +02:00
|
|
|
%%% <tt>"flat"</tt>, <tt>"hometree"</tt> or <tt>"blog"</tt>.</p>
|
2007-12-01 06:16:30 +01:00
|
|
|
|
|
|
|
%%% @type jid() = #jid{
|
|
|
|
%%% user = string(),
|
|
|
|
%%% server = string(),
|
|
|
|
%%% resource = string(),
|
|
|
|
%%% luser = string(),
|
|
|
|
%%% lserver = string(),
|
|
|
|
%%% lresource = string()}.
|
|
|
|
|
2009-01-03 01:29:36 +01:00
|
|
|
%%% @type ljid() = {User::string(), Server::string(), Resource::string()}.
|
2007-12-01 06:16:30 +01:00
|
|
|
|
|
|
|
%%% @type affiliation() = none | owner | publisher | outcast.
|
|
|
|
%%% @type subscription() = none | pending | unconfigured | subscribed.
|
|
|
|
|
2009-05-01 01:17:38 +02:00
|
|
|
%%% internal pubsub index table
|
|
|
|
-record(pubsub_index, {index, last, free}).
|
|
|
|
|
2007-12-01 06:16:30 +01:00
|
|
|
%%% @type pubsubNode() = #pubsub_node{
|
|
|
|
%%% nodeid = {Host::host(), Node::pubsubNode()},
|
2009-05-20 00:29:28 +02:00
|
|
|
%%% parentid = Node::pubsubNode(),
|
2009-10-13 23:36:32 +02:00
|
|
|
%%% nodeidx = int(),
|
2007-12-01 06:16:30 +01:00
|
|
|
%%% type = nodeType(),
|
2009-10-13 23:36:32 +02:00
|
|
|
%%% options = [nodeOption()]}.
|
2007-12-01 06:16:30 +01:00
|
|
|
%%% <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>parentid</tt> and <tt>type</tt> fields are indexed.</p>
|
2009-10-13 23:36:32 +02:00
|
|
|
%%% <p><tt>nodeidx</tt> can be anything you want.</p>
|
2007-12-01 06:16:30 +01:00
|
|
|
-record(pubsub_node, {nodeid,
|
2009-05-01 01:17:38 +02:00
|
|
|
id,
|
2009-08-25 19:14:30 +02:00
|
|
|
parents = [],
|
2009-05-29 02:27:26 +02:00
|
|
|
type = "flat",
|
2007-12-01 06:16:30 +01:00
|
|
|
owners = [],
|
|
|
|
options = []
|
|
|
|
}).
|
|
|
|
|
|
|
|
%%% @type pubsubState() = #pubsub_state{
|
2009-10-13 23:36:32 +02:00
|
|
|
%%% stateid = {ljid(), nodeidx()},
|
2007-12-01 06:16:30 +01:00
|
|
|
%%% items = [ItemId::string()],
|
|
|
|
%%% affiliation = affiliation(),
|
2009-08-25 19:14:30 +02:00
|
|
|
%%% subscriptions = [subscription()]}.
|
2007-12-01 06:16:30 +01:00
|
|
|
%%% <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,
|
2009-08-25 21:54:44 +02:00
|
|
|
subscriptions = []
|
2007-12-01 06:16:30 +01:00
|
|
|
}).
|
|
|
|
|
2009-05-01 01:17:38 +02:00
|
|
|
%%% @type pubsubItem() = #pubsub_item{
|
2009-10-13 23:36:32 +02:00
|
|
|
%%% itemid = {ItemId::string(), nodeidx()},
|
2009-05-20 00:29:28 +02:00
|
|
|
%%% creation = {now(), ljid()},
|
|
|
|
%%% modification = {now(), ljid()},
|
2009-05-01 01:17:38 +02:00
|
|
|
%%% payload = XMLContent::string()}.
|
2007-12-01 06:16:30 +01:00
|
|
|
%%% <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 = []
|
|
|
|
}).
|
|
|
|
|
2009-08-25 19:14:30 +02:00
|
|
|
%% @type pubsubSubscription() = #pubsub_subscription{
|
|
|
|
%% subid = string(),
|
|
|
|
%% state_key = {ljid(), pubsubNodeId()},
|
|
|
|
%% options = [{atom(), term()}]
|
|
|
|
%% }.
|
|
|
|
%% <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}).
|