aboutsummaryrefslogtreecommitdiff
path: root/src/gen_pubsub_nodetree.erl
blob: 190051fd798e995c6dbc44e171e076b094da9ff8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
%%%----------------------------------------------------------------------
%%% File    : gen_pubsub_nodetree.erl
%%% Author  : Christophe Romain <christophe.romain@process-one.net>
%%% Purpose : Define the pubsub node tree plugin behaviour
%%% Created :  1 Dec 2007 by Christophe Romain <christophe.romain@process-one.net>
%%%
%%%
%%% ejabberd, Copyright (C) 2002-2022   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.,
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
%%%
%%%----------------------------------------------------------------------

-module(gen_pubsub_nodetree).


-type(host() :: mod_pubsub:host()).
-type(nodeId() :: mod_pubsub:nodeId()).
-type(nodeIdx() :: mod_pubsub:nodeIdx()).
-type(pubsubNode() :: mod_pubsub:pubsubNode()).
-type(nodeOptions() :: mod_pubsub:nodeOptions()).

-callback init(Host :: host(),
	ServerHost :: binary(),
	Opts :: [any()]) -> atom().

-include_lib("xmpp/include/xmpp.hrl").

-callback terminate(Host :: host(), ServerHost :: binary()) -> atom().

-callback options() -> nodeOptions().

-callback set_node(PubsubNode :: pubsubNode()) ->
    ok | {result, NodeIdx::nodeIdx()} | {error, stanza_error()}.

-callback get_node(Host   :: host(),
	NodeId :: nodeId(),
	From   :: jid:jid()) ->
    pubsubNode() |
    {error, stanza_error()}.

-callback get_node(Host :: host(),
	NodeId :: nodeId()) ->
    pubsubNode() |
    {error, stanza_error()}.

-callback get_node(NodeIdx :: nodeIdx()) ->
    pubsubNode() |
    {error, stanza_error()}.

-callback get_nodes(Host :: host(),
		    Limit :: non_neg_integer() | infinity)->
    [pubsubNode()].

-callback get_nodes(Host :: host())->
    [pubsubNode()].

-callback get_all_nodes(Host :: host()) ->
    [pubsubNode()].

-callback get_parentnodes(Host :: host(),
	NodeId :: nodeId(),
	From :: jid:jid()) ->
    [pubsubNode()] |
    {error, stanza_error()}.

-callback get_parentnodes_tree(Host :: host(),
	NodeId :: nodeId(),
	From :: jid:jid()) ->
    [{0, [pubsubNode(),...]}].

-callback get_subnodes(Host :: host(),
		       NodeId :: nodeId(),
		       Limit :: non_neg_integer() | infinity) ->
    [pubsubNode()].

-callback get_subnodes_tree(Host :: host(),
	NodeId :: nodeId(),
	From :: jid:jid()) ->
    [pubsubNode()].

-callback create_node(Host :: host(),
	NodeId :: nodeId(),
	Type :: binary(),
	Owner :: jid:jid(),
	Options :: nodeOptions(),
	Parents :: [nodeId()]) ->
    {ok, NodeIdx::nodeIdx()} |
    {error, stanza_error()} |
    {error, {virtual, {host(), nodeId()} | nodeId()}}.

-callback delete_node(Host :: host(),
	NodeId :: nodeId()) ->
    [pubsubNode()].