2015-12-15 16:11:29 +01:00
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
%%% File : gen_pubsub_node.erl
|
|
|
|
%%% Author : Christophe Romain <christophe.romain@process-one.net>
|
|
|
|
%%% Purpose : Define pubsub plugin behaviour
|
|
|
|
%%% Created : 1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net>
|
2013-03-14 10:33:02 +01:00
|
|
|
%%%
|
|
|
|
%%%
|
2019-01-08 22:53:27 +01:00
|
|
|
%%% ejabberd, Copyright (C) 2002-2019 ProcessOne
|
2007-12-01 06:16:30 +01:00
|
|
|
%%%
|
2015-12-15 16:11:29 +01:00
|
|
|
%%% 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.
|
2007-12-24 14:57:53 +01:00
|
|
|
%%%
|
2015-12-15 16:11:29 +01:00
|
|
|
%%% 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.,
|
|
|
|
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
%%%
|
|
|
|
%%%----------------------------------------------------------------------
|
2007-12-01 06:16:30 +01:00
|
|
|
|
|
|
|
-module(gen_pubsub_node).
|
|
|
|
|
2016-08-30 08:48:08 +02:00
|
|
|
-include("xmpp.hrl").
|
2013-03-14 10:33:02 +01:00
|
|
|
|
2015-04-08 17:12:05 +02:00
|
|
|
-type(host() :: mod_pubsub:host()).
|
|
|
|
-type(nodeId() :: mod_pubsub:nodeId()).
|
|
|
|
-type(nodeIdx() :: mod_pubsub:nodeIdx()).
|
|
|
|
-type(itemId() :: mod_pubsub:itemId()).
|
|
|
|
-type(pubsubNode() :: mod_pubsub:pubsubNode()).
|
|
|
|
-type(pubsubState() :: mod_pubsub:pubsubState()).
|
|
|
|
-type(pubsubItem() :: mod_pubsub:pubsubItem()).
|
|
|
|
-type(subOptions() :: mod_pubsub:subOptions()).
|
2015-07-01 17:18:32 +02:00
|
|
|
-type(pubOptions() :: mod_pubsub:pubOptions()).
|
2015-04-08 17:12:05 +02:00
|
|
|
-type(affiliation() :: mod_pubsub:affiliation()).
|
|
|
|
-type(subscription() :: mod_pubsub:subscription()).
|
|
|
|
-type(subId() :: mod_pubsub:subId()).
|
|
|
|
-type(accessModel() :: mod_pubsub:accessModel()).
|
|
|
|
-type(publishModel() :: mod_pubsub:publishModel()).
|
|
|
|
-type(payload() :: mod_pubsub:payload()).
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback init(Host :: binary(),
|
2015-04-08 17:12:05 +02:00
|
|
|
ServerHost :: binary(),
|
|
|
|
Opts :: [any()]) -> atom().
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback terminate(Host :: host(),
|
2015-04-08 17:12:05 +02:00
|
|
|
ServerHost :: binary()) -> atom().
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback options() -> [{atom(), any()}].
|
|
|
|
|
|
|
|
-callback features() -> [binary()].
|
|
|
|
|
|
|
|
-callback create_node_permission(Host :: host(),
|
2015-04-08 17:12:05 +02:00
|
|
|
ServerHost :: binary(),
|
|
|
|
Node :: nodeId(),
|
|
|
|
ParentNode :: nodeId(),
|
|
|
|
Owner :: jid(), Access :: atom()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, boolean()}.
|
|
|
|
|
|
|
|
-callback create_node(NodeIdx :: nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Owner :: jid()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, {default, broadcast}}.
|
|
|
|
|
|
|
|
-callback delete_node(Nodes :: [pubsubNode(),...]) ->
|
|
|
|
{result,
|
2015-04-08 17:12:05 +02:00
|
|
|
{default, broadcast,
|
|
|
|
[{pubsubNode(),
|
|
|
|
[{ljid(), [{subscription(), subId()}]},...]},...]
|
|
|
|
}
|
|
|
|
}
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
|
{result,
|
2015-04-08 17:12:05 +02:00
|
|
|
{[],
|
|
|
|
[{pubsubNode(),
|
|
|
|
[{ljid(), [{subscription(), subId()}]},...]},...]
|
|
|
|
}
|
|
|
|
}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback purge_node(NodeIdx :: nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Owner :: jid()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, {default, broadcast}} |
|
2017-02-18 07:36:27 +01:00
|
|
|
{error, stanza_error()}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback subscribe_node(NodeIdx :: nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Sender :: jid(),
|
|
|
|
Subscriber :: jid(),
|
|
|
|
AccessModel :: accessModel(),
|
|
|
|
SendLast :: 'never' | 'on_sub' | 'on_sub_and_presence',
|
|
|
|
PresenceSubscription :: boolean(),
|
|
|
|
RosterGroup :: boolean(),
|
|
|
|
Options :: subOptions()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, {default, subscribed, subId()}} |
|
|
|
|
{result, {default, subscribed, subId(), send_last}} |
|
|
|
|
{result, {default, pending, subId()}} |
|
2017-02-18 07:36:27 +01:00
|
|
|
{error, stanza_error()}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback unsubscribe_node(NodeIdx :: nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Sender :: jid(),
|
|
|
|
Subscriber :: jid(),
|
|
|
|
SubId :: subId()) ->
|
2017-02-18 07:36:27 +01:00
|
|
|
{result, []} |
|
|
|
|
{error, stanza_error()}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback publish_item(NodeId :: nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Publisher :: jid(),
|
|
|
|
PublishModel :: publishModel(),
|
|
|
|
Max_Items :: non_neg_integer(),
|
|
|
|
ItemId :: <<>> | itemId(),
|
2015-07-01 17:18:32 +02:00
|
|
|
Payload :: payload(),
|
|
|
|
Options :: pubOptions()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, {default, broadcast, [itemId()]}} |
|
2017-02-18 07:36:27 +01:00
|
|
|
{error, stanza_error()}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback delete_item(NodeIdx :: nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Publisher :: jid(),
|
|
|
|
PublishModel :: publishModel(),
|
|
|
|
ItemId :: <<>> | itemId()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, {default, broadcast}} |
|
2017-02-18 07:36:27 +01:00
|
|
|
{error, stanza_error()}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback remove_extra_items(NodeIdx :: nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Max_Items :: unlimited | non_neg_integer(),
|
|
|
|
ItemIds :: [itemId()]) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, {[itemId()], [itemId()]}
|
2015-04-08 17:12:05 +02:00
|
|
|
}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback get_node_affiliations(NodeIdx :: nodeIdx()) ->
|
|
|
|
{result, [{ljid(), affiliation()}]}.
|
|
|
|
|
|
|
|
-callback get_entity_affiliations(Host :: host(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Owner :: jid()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, [{pubsubNode(), affiliation()}]}.
|
|
|
|
|
|
|
|
-callback get_affiliation(NodeIdx :: nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Owner :: jid()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, affiliation()}.
|
|
|
|
|
|
|
|
-callback set_affiliation(NodeIdx :: nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Owner :: jid(),
|
|
|
|
Affiliation :: affiliation()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
ok |
|
2017-02-18 07:36:27 +01:00
|
|
|
{error, stanza_error()}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback get_node_subscriptions(NodeIdx :: nodeIdx()) ->
|
|
|
|
{result,
|
2015-04-08 17:12:05 +02:00
|
|
|
[{ljid(), subscription(), subId()}] |
|
|
|
|
[{ljid(), none},...]
|
|
|
|
}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback get_entity_subscriptions(Host :: host(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Key :: jid()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, [{pubsubNode(), subscription(), subId(), ljid()}]
|
2015-04-08 17:12:05 +02:00
|
|
|
}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback get_subscriptions(NodeIdx :: nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Owner :: jid()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, [{subscription(), subId()}]}.
|
|
|
|
|
|
|
|
-callback get_pending_nodes(Host :: host(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Owner :: jid()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, [nodeId()]}.
|
|
|
|
|
|
|
|
-callback get_states(NodeIdx::nodeIdx()) ->
|
|
|
|
{result, [pubsubState()]}.
|
|
|
|
|
|
|
|
-callback get_state(NodeIdx :: nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
Key :: ljid()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
pubsubState().
|
|
|
|
|
|
|
|
-callback set_state(State::pubsubState()) ->
|
|
|
|
ok |
|
2017-02-18 07:36:27 +01:00
|
|
|
{error, stanza_error()}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
2016-08-30 08:48:08 +02:00
|
|
|
-callback get_items(nodeIdx(), jid(), accessModel(),
|
|
|
|
boolean(), boolean(), binary(),
|
|
|
|
undefined | rsm_set()) ->
|
2016-09-08 16:08:48 +02:00
|
|
|
{result, {[pubsubItem()], undefined | rsm_set()}} | {error, stanza_error()}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
2016-08-30 08:48:08 +02:00
|
|
|
-callback get_items(nodeIdx(), jid(), undefined | rsm_set()) ->
|
|
|
|
{result, {[pubsubItem()], undefined | rsm_set()}}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
2017-03-30 14:26:30 +02:00
|
|
|
-callback get_last_items(nodeIdx(), jid(), undefined | rsm_set()) ->
|
|
|
|
{result, {[pubsubItem()], undefined | rsm_set()}}.
|
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-callback get_item(NodeIdx :: nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
ItemId :: itemId(),
|
|
|
|
JID :: jid(),
|
|
|
|
AccessModel :: accessModel(),
|
|
|
|
PresenceSubscription :: boolean(),
|
|
|
|
RosterGroup :: boolean(),
|
|
|
|
SubId :: subId()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, pubsubItem()} |
|
2017-02-18 07:36:27 +01:00
|
|
|
{error, stanza_error()}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback get_item(NodeIdx :: nodeIdx(),
|
2015-04-08 17:12:05 +02:00
|
|
|
ItemId :: itemId()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
{result, pubsubItem()} |
|
2017-02-18 07:36:27 +01:00
|
|
|
{error, stanza_error()}.
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-callback set_item(Item :: pubsubItem()) ->
|
|
|
|
ok.
|
|
|
|
% | {error, _}.
|
|
|
|
|
|
|
|
-callback get_item_name(Host :: host(),
|
2015-04-08 17:12:05 +02:00
|
|
|
ServerHost :: binary(),
|
|
|
|
Node :: nodeId()) ->
|
2013-03-14 10:33:02 +01:00
|
|
|
itemId().
|
|
|
|
|
|
|
|
-callback node_to_path(Node :: nodeId()) ->
|
|
|
|
[nodeId()].
|
|
|
|
|
|
|
|
-callback path_to_node(Node :: [nodeId()]) ->
|
|
|
|
nodeId().
|