25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-24 17:29:28 +01:00

pubsub: added configuration option in guide.tex, added last item cache, use default node type if given type is not configured, make node_flat the default node plugin. caps: improve cache handling

SVN Revision: 2114
This commit is contained in:
Christophe Romain 2009-05-28 23:21:50 +00:00
parent 0bbbf468f0
commit a16230c9ca
15 changed files with 383 additions and 261 deletions

View File

@ -3268,11 +3268,28 @@ Options:
\titem{access\_createnode} \ind{options!access\_createnode}
This option restricts which users are allowed to create pubsub nodes using
ACL and ACCESS. The default value is \term{pubsub\_createnode}. % Not clear enough + do not use abbreviations.
\titem{plugins} To specify which pubsub node plugins to use. If not defined, the default
\titem{plugins} \ind{options!plugins}
To specify which pubsub node plugins to use. If not defined, the default
pubsub plugin is always used.
\titem{nodetree} To specify which nodetree to use. If not defined, the default pubsub
nodetree is used. Nodetrees are default and virtual. Only one nodetree can be used
\titem{nodetree} \ind{options!nodetree}
To specify which nodetree to use. If not defined, the default pubsub
nodetree is used. Only one nodetree can be used per host,
and is shared by all node plugins.
\titem{pep\_sendlast\_offline} \ind{options!pep\_sendlast\_offline}
To specify whether or not we should get last published PEP items
from users in our roster which are offline when we connect. Value is true or false.
If not defined, pubsub assumes false so we only get last items of online contacts.
\titem{last\_item\_cache} \ind{options!last\_item\_cache}
To specify whether or not pubsub should cache last items. Value is true
or false. If not defined, pubsub do not cache last items. On systems with not so many nodes,
caching last items speeds up pubsub and allows to raise user connection rate. The cost is memory
usage, as every item is stored in memory.
\titem{pep\_mapping} \ind{pep\_mapping}
This allow to define a Key-Value list to choose defined node plugins on given PEP namespace.
The following example will use node\_tune instead of node\_pep for every PEP node with tune namespace:
\begin{verbatim}
{mod_pubsub, [{pep_mapping, [{"http://jabber.org/protocol/tune", "tune"}]}]}
\end{verbatim}
%\titem{served\_hosts} \ind{options!served\_hosts}
% This option allows to create additional pubsub virtual hosts in a single module instance.
\end{description}

View File

@ -485,9 +485,11 @@
{mod_privacy, []},
{mod_private, []},
%%{mod_proxy65,[]},
{mod_pubsub, [ % requires mod_caps
{mod_pubsub, [
{access_createnode, pubsub_createnode},
{plugins, ["default", "pep"]}
{pep_sendlast_offline, false},
{last_item_cache, false},
{plugins, ["flat", "pep"]} % pep requires mod_caps
]},
{mod_register, [
%%

View File

@ -59,7 +59,8 @@
%% hook handlers
-export([receive_packet/3,
receive_packet/4,
presence_probe/3]).
presence_probe/3,
remove_connection/3]).
-include("ejabberd.hrl").
@ -202,7 +203,20 @@ receive_packet(From, To, Packet) when ?IS_PRESENCE(Packet) ->
'unsubscribed' ->
ok;
'unavailable' ->
clear_caps(From);
{_, S1, _} = jlib:short_prepd_jid(From),
case jlib:short_prepd_jid(To) of
{_, S1, _} -> ok;
_ -> clear_caps(From)
end;
%% TODO: probe client, and clean only if no answers
%% as far as protocol does not allow inter-server communication to
%% let remote server handle it's own caps to decide which user is to be
%% notified, we must keep a cache of online status of external contacts
%% this is absolutely not scallable, but we have no choice for now
%% we can only use unavailable presence, but if remote user just remove a local user
%% from its roster, then it's considered as offline, so he does not receive local PEP
%% anymore until he login again.
%% This is tracked in EJAB-943
_ ->
ServerString = exmpp_jid:ldomain_as_list(To),
Els = Packet#xmlel.children,
@ -218,6 +232,9 @@ presence_probe(From, To, _) ->
ServerString = exmpp_jid:ldomain_as_list(To),
wait_caps(ServerString, From).
remove_connection(_SID, JID, _Info) ->
clear_caps(JID).
caps_to_binary(#caps{node = Node, version = Version, exts = Exts}) ->
BExts = [list_to_binary(Ext) || Ext <- Exts],
#caps{node = list_to_binary(Node), version = list_to_binary(Version), exts = BExts}.
@ -249,6 +266,7 @@ init([Host, _Opts]) ->
ejabberd_hooks:add(user_receive_packet, Host, ?MODULE, receive_packet, 30),
ejabberd_hooks:add(s2s_receive_packet, Host, ?MODULE, receive_packet, 30),
ejabberd_hooks:add(presence_probe_hook, Host, ?MODULE, presence_probe, 20),
ejabberd_hooks:add(sm_remove_connection_hook, Host, ?MODULE, remove_connection, 20),
{ok, #state{host = Host}}.
maybe_get_features(#caps{node = Node, version = Version, exts = Exts}) ->
@ -418,6 +436,7 @@ terminate(_Reason, State) ->
ejabberd_hooks:delete(user_receive_packet, Host, ?MODULE, receive_packet, 30),
ejabberd_hooks:delete(s2s_receive_packet, Host, ?MODULE, receive_packet, 30),
ejabberd_hooks:delete(presence_probe_hook, Host, ?MODULE, presence_probe, 20),
ejabberd_hooks:delete(sm_remove_connection_hook, Host, ?MODULE, remove_connection, 20),
ok.
code_change(_OldVsn, State, _Extra) ->

View File

@ -39,7 +39,7 @@
-module(mod_pubsub).
-author('christophe.romain@process-one.net').
-version('1.12-05').
-version('1.12-06').
-behaviour(gen_server).
-behaviour(gen_mod).
@ -49,8 +49,8 @@
-include("ejabberd.hrl").
-include("pubsub.hrl").
-define(STDTREE, "default").
-define(STDNODE, "default").
-define(STDTREE, "tree").
-define(STDNODE, "flat").
-define(PEPNODE, "pep").
%% exports for hooks
@ -78,6 +78,9 @@
publish_item/6,
delete_item/4,
send_items/6,
get_items/2,
get_item/3,
get_cached_item/2,
broadcast_stanza/7,
get_configure/5,
set_configure/5,
@ -120,7 +123,8 @@
host,
access,
pep_mapping = [],
pep_sendlast_offline,
pep_sendlast_offline = false,
last_item_cache = false,
nodetree = ?STDTREE,
plugins = [?STDNODE],
send_loop}).
@ -165,17 +169,21 @@ init([ServerHost, Opts]) ->
Access = gen_mod:get_opt(access_createnode, Opts, all),
PepOffline = gen_mod:get_opt(pep_sendlast_offline, Opts, false),
IQDisc = gen_mod:get_opt(iqdisc, Opts, one_queue),
LastItemCache = gen_mod:get_opt(last_item_cache, Opts, false),
ServerHostB = list_to_binary(ServerHost),
pubsub_index:init(Host, ServerHost, Opts),
ets:new(gen_mod:get_module_proc(Host, pubsub_state), [set, named_table]),
ets:new(gen_mod:get_module_proc(ServerHost, pubsub_state), [set, named_table]),
ets:new(gen_mod:get_module_proc(Host, config), [set, named_table]),
ets:new(gen_mod:get_module_proc(ServerHostB, config), [set, named_table]),
ets:new(gen_mod:get_module_proc(Host, last_items), [set, named_table]),
ets:new(gen_mod:get_module_proc(ServerHostB, last_items), [set, named_table]),
{Plugins, NodeTree, PepMapping} = init_plugins(Host, ServerHost, Opts),
mod_disco:register_feature(ServerHost, ?NS_PUBSUB_s),
ets:insert(gen_mod:get_module_proc(Host, pubsub_state), {nodetree, NodeTree}),
ets:insert(gen_mod:get_module_proc(Host, pubsub_state), {plugins, Plugins}),
ets:insert(gen_mod:get_module_proc(ServerHost, pubsub_state), {nodetree, NodeTree}),
ets:insert(gen_mod:get_module_proc(ServerHost, pubsub_state), {plugins, Plugins}),
ets:insert(gen_mod:get_module_proc(ServerHost, pubsub_state), {pep_mapping, PepMapping}),
ets:insert(gen_mod:get_module_proc(Host, config), {nodetree, NodeTree}),
ets:insert(gen_mod:get_module_proc(Host, config), {plugins, Plugins}),
ets:insert(gen_mod:get_module_proc(Host, config), {last_item_cache, LastItemCache}),
ets:insert(gen_mod:get_module_proc(ServerHostB, config), {nodetree, NodeTree}),
ets:insert(gen_mod:get_module_proc(ServerHostB, config), {plugins, Plugins}),
ets:insert(gen_mod:get_module_proc(ServerHostB, config), {pep_mapping, PepMapping}),
ejabberd_hooks:add(disco_sm_identity, ServerHostB, ?MODULE, disco_sm_identity, 75),
ejabberd_hooks:add(disco_sm_features, ServerHostB, ?MODULE, disco_sm_features, 75),
ejabberd_hooks:add(disco_sm_items, ServerHostB, ?MODULE, disco_sm_items, 75),
@ -204,6 +212,7 @@ init([ServerHost, Opts]) ->
access = Access,
pep_mapping = PepMapping,
pep_sendlast_offline = PepOffline,
last_item_cache = LastItemCache,
nodetree = NodeTree,
plugins = Plugins},
SendLoop = spawn(?MODULE, send_loop, [State]),
@ -641,8 +650,8 @@ out_subscription(User, Server, JID, subscribed) ->
gen_server:cast(Proc, {presence, U, S, Rs, Owner});
out_subscription(_, _, _, _) ->
ok.
in_subscription(_, User, Server, Subscriber, unsubscribed, _) ->
Owner = exmpp_jid:make_jid(User, Server, ""),
in_subscription(_, User, Server, Owner, unsubscribed, _) ->
Subscriber = exmpp_jid:make_jid(User, Server, ""),
Proc = gen_mod:get_module_proc(Server, ?PROCNAME),
gen_server:cast(Proc, {unsubscribe, Subscriber, Owner});
in_subscription(_, _, _, _, _, _) ->
@ -1534,7 +1543,8 @@ delete_node(Host, Node, Owner) ->
NodeId = RNode#pubsub_node.id,
Type = RNode#pubsub_node.type,
Options = RNode#pubsub_node.options,
broadcast_removed_node(RH, RN, NodeId, Type, Options, RSubscriptions)
broadcast_removed_node(RH, RN, NodeId, Type, Options, RSubscriptions),
unset_cached_item(RH, NodeId)
end, Removed),
case Result of
default -> {result, Reply};
@ -1756,6 +1766,7 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
Type = TNode#pubsub_node.type,
Options = TNode#pubsub_node.options,
broadcast_publish_item(Host, Node, NodeId, Type, Options, Removed, ItemId, jlib:short_prepd_jid(Publisher), Payload),
set_cached_item(Host, NodeId, ItemId, Payload),
case Result of
default -> {result, Reply};
_ -> {result, Result}
@ -1765,12 +1776,14 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
Type = TNode#pubsub_node.type,
Options = TNode#pubsub_node.options,
broadcast_retract_items(Host, Node, NodeId, Type, Options, Removed),
set_cached_item(Host, NodeId, ItemId, Payload),
{result, Reply};
{result, {TNode, {Result, Removed}}} ->
NodeId = TNode#pubsub_node.id,
Type = TNode#pubsub_node.type,
Options = TNode#pubsub_node.options,
broadcast_retract_items(Host, Node, NodeId, Type, Options, Removed),
set_cached_item(Host, NodeId, ItemId, Payload),
{result, Result};
{result, {_, default}} ->
{result, Reply};
@ -1842,6 +1855,10 @@ delete_item(Host, Node, Publisher, ItemId, ForceNotify) ->
Type = TNode#pubsub_node.type,
Options = TNode#pubsub_node.options,
broadcast_retract_items(Host, Node, NodeId, Type, Options, [ItemId], ForceNotify),
case get_cached_item(Host, NodeId) of
#pubsub_item{itemid = {ItemId, NodeId}, _ = '_'} -> unset_cached_item(Host, NodeId);
_ -> ok
end,
case Result of
default -> {result, Reply};
_ -> {result, Result}
@ -1895,6 +1912,7 @@ purge_node(Host, Node, Owner) ->
Type = TNode#pubsub_node.type,
Options = TNode#pubsub_node.options,
broadcast_purge_node(Host, Node, NodeId, Type, Options),
unset_cached_item(Host, NodeId),
case Result of
default -> {result, Reply};
_ -> {result, Result}
@ -1973,6 +1991,22 @@ get_items(Host, Node, From, SubId, SMaxItems, ItemIDs) ->
Error
end
end.
get_items(Host, Node) ->
Action = fun(#pubsub_node{type = Type, id = NodeId}) ->
node_call(Type, get_items, [NodeId, service_jid(Host)])
end,
case transaction(Host, Node, Action, sync_dirty) of
{result, {_, Items}} -> Items;
Error -> Error
end.
get_item(Host, Node, ItemId) ->
Action = fun(#pubsub_node{type = Type, id = NodeId}) ->
node_call(Type, get_item, [NodeId, ItemId])
end,
case transaction(Host, Node, Action, sync_dirty) of
{result, {_, Items}} -> Items;
Error -> Error
end.
%% @spec (Host, Node, NodeId, Type, LJID, Number) -> any()
%% Host = host()
@ -1984,7 +2018,15 @@ get_items(Host, Node, From, SubId, SMaxItems, ItemIDs) ->
%% @doc <p>Resend the items of a node to the user.</p>
%% @todo use cache-last-item feature
send_items(Host, Node, NodeId, Type, LJID, last) ->
send_items(Host, Node, NodeId, Type, LJID, 1);
case get_cached_item(Host, NodeId) of
undefined ->
send_items(Host, Node, NodeId, Type, LJID, 1);
LastItem ->
Stanza = event_stanza(
[{xmlelement, "items", nodeAttr(Node),
itemsEls([LastItem])}]),
ejabberd_router ! {route, service_jid(Host), jlib:make_jid(LJID), Stanza}
end;
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) ->
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
{result, []} ->
@ -2909,23 +2951,65 @@ set_xoption([_ | Opts], NewOpts) ->
% skip unknown field
set_xoption(Opts, NewOpts).
%%%% last item cache handling
set_cached_item({_, ServerHost, _}, NodeId, ItemId, Payload) ->
set_cached_item(ServerHost, NodeId, ItemId, Payload);
set_cached_item(Host, NodeId, ItemId, Payload) ->
case ets:lookup(gen_mod:get_module_proc(Host, config), last_item_cache) of
[{last_item_cache, true}] ->
ets:insert(gen_mod:get_module_proc(Host, last_items), {NodeId, {ItemId, Payload}});
_ ->
ok
end.
unset_cached_item({_, ServerHost, _}, NodeId) ->
unset_cached_item(ServerHost, NodeId);
unset_cached_item(Host, NodeId) ->
case ets:lookup(gen_mod:get_module_proc(Host, config), last_item_cache) of
[{last_item_cache, true}] ->
ets:delete(gen_mod:get_module_proc(Host, last_items), NodeId);
_ ->
ok
end.
get_cached_item({_, ServerHost, _}, NodeId) ->
get_cached_item(ServerHost, NodeId);
get_cached_item(Host, NodeId) ->
case ets:lookup(gen_mod:get_module_proc(Host, config), last_item_cache) of
[{last_item_cache, true}] ->
case ets:lookup(gen_mod:get_module_proc(Host, last_items), NodeId) of
[{NodeId, {ItemId, Payload}}] ->
#pubsub_item{itemid = {ItemId, NodeId}, payload = Payload};
_ ->
undefined
end;
_ ->
undefined
end.
%%%% plugin handling
plugins(Host) ->
case ets:lookup(gen_mod:get_module_proc(Host, pubsub_state), plugins) of
case ets:lookup(gen_mod:get_module_proc(Host, config), plugins) of
[{plugins, []}] -> [?STDNODE];
[{plugins, PL}] -> PL;
_ -> [?STDNODE]
end.
select_type(ServerHost, Host, Node, Type)->
?DEBUG("SELECT_TYPE : ~p~n", [[ServerHost, Host, Node, Type]]),
case Host of
select_type(ServerHost, Host, Node, Type) when is_list(ServerHost) ->
select_type(list_to_binary(ServerHost), Host, Node, Type);
select_type(ServerHost, Host, Node, Type) ->
SelectedType = case Host of
{_User, _Server, _Resource} ->
case ets:lookup(gen_mod:get_module_proc(ServerHost, pubsub_state), pep_mapping) of
[{pep_mapping, PM}] -> ?DEBUG("SELECT_TYPE : ~p~n", [PM]), proplists:get_value(Node, PM, ?PEPNODE);
R -> ?DEBUG("SELECT_TYPE why ?: ~p~n", [R]), ?PEPNODE
case ets:lookup(gen_mod:get_module_proc(ServerHost, config), pep_mapping) of
[{pep_mapping, PM}] -> proplists:get_value(Node, PM, ?PEPNODE);
_ -> ?PEPNODE
end;
_ ->
Type
end,
ConfiguredTypes = plugins(ServerHost),
case lists:member(SelectedType, ConfiguredTypes) of
true -> SelectedType;
false -> hd(ConfiguredTypes)
end.
select_type(ServerHost, Host, Node) ->
select_type(ServerHost, Host, Node, hd(plugins(ServerHost))).
@ -2997,7 +3081,7 @@ tree_call({_User, Server, _Resource}, Function, Args) ->
tree_call(Server, Function, Args);
tree_call(Host, Function, Args) ->
?DEBUG("tree_call ~p ~p ~p",[Host, Function, Args]),
Module = case ets:lookup(gen_mod:get_module_proc(Host, pubsub_state), nodetree) of
Module = case ets:lookup(gen_mod:get_module_proc(Host, config), nodetree) of
[{nodetree, N}] -> N;
_ -> list_to_atom(?TREE_PREFIX ++ ?STDTREE)
end,

View File

@ -34,7 +34,7 @@
%% it's possible not to define some function at all
%% in that case, warning will be generated at compilation
%% and function call will fail,
%% then mod_pubsub will call function from node_default
%% then mod_pubsub will call function from node_hometree
%% (this makes code cleaner, but execution a little bit longer)
%% API definition
@ -69,10 +69,10 @@
init(Host, ServerHost, Opts) ->
node_default:init(Host, ServerHost, Opts).
node_hometree:init(Host, ServerHost, Opts).
terminate(Host, ServerHost) ->
node_default:terminate(Host, ServerHost).
node_hometree:terminate(Host, ServerHost).
options() ->
[{node_type, __TO_BE_DEFINED__},
@ -109,76 +109,76 @@ features() ->
].
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_default:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
node_hometree:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
node_hometree:create_node(NodeId, Owner).
delete_node(Removed) ->
node_default:delete_node(Removed).
node_hometree:delete_node(Removed).
subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
node_hometree:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
node_hometree:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
node_hometree:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
node_hometree:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(NodeId, Publisher, PublishModel, ItemId) ->
node_default:delete_item(NodeId, Publisher, PublishModel, ItemId).
node_hometree:delete_item(NodeId, Publisher, PublishModel, ItemId).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
node_hometree:purge_node(NodeId, Owner).
get_entity_affiliations(Host, Owner) ->
node_default:get_entity_affiliations(Host, Owner).
node_hometree:get_entity_affiliations(Host, Owner).
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
node_hometree:get_node_affiliations(NodeId).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
node_hometree:get_affiliation(NodeId, Owner).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
node_hometree:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) ->
node_default:get_entity_subscriptions(Host, Owner).
node_hometree:get_entity_subscriptions(Host, Owner).
get_node_subscriptions(NodeId) ->
node_default:get_node_subscriptions(NodeId).
node_hometree:get_node_subscriptions(NodeId).
get_subscription(NodeId, Owner) ->
node_default:get_subscription(NodeId, Owner).
node_hometree:get_subscription(NodeId, Owner).
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
node_hometree:set_subscription(NodeId, Owner, Subscription).
get_states(NodeId) ->
node_default:get_states(NodeId).
node_hometree:get_states(NodeId).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
node_hometree:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
node_hometree:set_state(State).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
node_hometree:get_items(NodeId, From).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId)
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
node_hometree:get_item(NodeId, ItemId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).
node_hometree:set_item(Item).

View File

@ -37,7 +37,7 @@
%% it's possible not to define some function at all
%% in that case, warning will be generated at compilation
%% and function call will fail,
%% then mod_pubsub will call function from node_default
%% then mod_pubsub will call function from node_hometree
%% (this makes code cleaner, but execution a little bit longer)
%% API definition
@ -73,10 +73,10 @@
init(Host, ServerHost, Opts) ->
node_default:init(Host, ServerHost, Opts).
node_hometree:init(Host, ServerHost, Opts).
terminate(Host, ServerHost) ->
node_default:terminate(Host, ServerHost).
node_hometree:terminate(Host, ServerHost).
options() ->
[{node_type, buddy},
@ -114,79 +114,79 @@ features() ->
].
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_default:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
node_hometree:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
node_hometree:create_node(NodeId, Owner).
delete_node(Removed) ->
node_default:delete_node(Removed).
node_hometree:delete_node(Removed).
subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
node_hometree:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
node_hometree:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
node_hometree:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
node_hometree:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(NodeId, Publisher, PublishModel, ItemId) ->
node_default:delete_item(NodeId, Publisher, PublishModel, ItemId).
node_hometree:delete_item(NodeId, Publisher, PublishModel, ItemId).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
node_hometree:purge_node(NodeId, Owner).
get_entity_affiliations(Host, Owner) ->
node_default:get_entity_affiliations(Host, Owner).
node_hometree:get_entity_affiliations(Host, Owner).
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
node_hometree:get_node_affiliations(NodeId).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
node_hometree:get_affiliation(NodeId, Owner).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
node_hometree:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) ->
node_default:get_entity_subscriptions(Host, Owner).
node_hometree:get_entity_subscriptions(Host, Owner).
get_node_subscriptions(NodeId) ->
node_default:get_node_subscriptions(NodeId).
node_hometree:get_node_subscriptions(NodeId).
get_subscription(NodeId, Owner) ->
node_default:get_subscription(NodeId, Owner).
node_hometree:get_subscription(NodeId, Owner).
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
node_hometree:set_subscription(NodeId, Owner, Subscription).
get_states(NodeId) ->
node_default:get_states(NodeId).
node_hometree:get_states(NodeId).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
node_hometree:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
node_hometree:set_state(State).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
node_hometree:get_items(NodeId, From).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
node_hometree:get_item(NodeId, ItemId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).
node_hometree:set_item(Item).
get_item_name(Host, Node, Id) ->
node_default:get_item_name(Host, Node, Id).
node_hometree:get_item_name(Host, Node, Id).

View File

@ -37,7 +37,7 @@
%% it's possible not to define some function at all
%% in that case, warning will be generated at compilation
%% and function call will fail,
%% then mod_pubsub will call function from node_default
%% then mod_pubsub will call function from node_hometree
%% (this makes code cleaner, but execution a little bit longer)
%% API definition
@ -73,10 +73,10 @@
init(Host, ServerHost, Opts) ->
node_default:init(Host, ServerHost, Opts).
node_hometree:init(Host, ServerHost, Opts).
terminate(Host, ServerHost) ->
node_default:terminate(Host, ServerHost).
node_hometree:terminate(Host, ServerHost).
options() ->
[{node_type, club},
@ -113,79 +113,79 @@ features() ->
].
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_default:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
node_hometree:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
node_hometree:create_node(NodeId, Owner).
delete_node(Removed) ->
node_default:delete_node(Removed).
node_hometree:delete_node(Removed).
subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
node_hometree:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
node_hometree:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
node_hometree:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
node_hometree:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(NodeId, Publisher, PublishModel, ItemId) ->
node_default:delete_item(NodeId, Publisher, PublishModel, ItemId).
node_hometree:delete_item(NodeId, Publisher, PublishModel, ItemId).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
node_hometree:purge_node(NodeId, Owner).
get_entity_affiliations(Host, Owner) ->
node_default:get_entity_affiliations(Host, Owner).
node_hometree:get_entity_affiliations(Host, Owner).
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
node_hometree:get_node_affiliations(NodeId).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
node_hometree:get_affiliation(NodeId, Owner).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
node_hometree:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) ->
node_default:get_entity_subscriptions(Host, Owner).
node_hometree:get_entity_subscriptions(Host, Owner).
get_node_subscriptions(NodeId) ->
node_default:get_node_subscriptions(NodeId).
node_hometree:get_node_subscriptions(NodeId).
get_subscription(NodeId, Owner) ->
node_default:get_subscription(NodeId, Owner).
node_hometree:get_subscription(NodeId, Owner).
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
node_hometree:set_subscription(NodeId, Owner, Subscription).
get_states(NodeId) ->
node_default:get_states(NodeId).
node_hometree:get_states(NodeId).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
node_hometree:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
node_hometree:set_state(State).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
node_hometree:get_items(NodeId, From).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
node_hometree:get_item(NodeId, ItemId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).
node_hometree:set_item(Item).
get_item_name(Host, Node, Id) ->
node_default:get_item_name(Host, Node, Id).
node_hometree:get_item_name(Host, Node, Id).

View File

@ -71,10 +71,10 @@
init(Host, ServerHost, Opts) ->
node_default:init(Host, ServerHost, Opts).
node_hometree:init(Host, ServerHost, Opts).
terminate(Host, ServerHost) ->
node_default:terminate(Host, ServerHost).
node_hometree:terminate(Host, ServerHost).
options() ->
[{node_type, dispatch},
@ -110,13 +110,13 @@ features() ->
].
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_default:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
node_hometree:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
node_hometree:create_node(NodeId, Owner).
delete_node(Removed) ->
node_default:delete_node(Removed).
node_hometree:delete_node(Removed).
subscribe_node(_NodeId, _Sender, _Subscriber, _AccessModel,
_SendLast, _PresenceSubscription, _RosterGroup) ->
@ -127,7 +127,7 @@ unsubscribe_node(_NodeId, _Sender, _Subscriber, _SubID) ->
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
lists:foreach(fun(SubNode) ->
node_default:publish_item(
node_hometree:publish_item(
SubNode#pubsub_node.id, Publisher, Model,
MaxItems, ItemId, Payload)
end, nodetree_default:get_subnodes(NodeId, Publisher)).
@ -151,7 +151,7 @@ get_affiliation(_NodeId, _Owner) ->
{result, []}.
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
node_hometree:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(_Host, _Owner) ->
{result, []}.
@ -159,37 +159,37 @@ get_entity_subscriptions(_Host, _Owner) ->
get_node_subscriptions(NodeId) ->
%% note: get_node_subscriptions is used for broadcasting
%% DO NOT REMOVE
node_default:get_node_subscriptions(NodeId).
node_hometree:get_node_subscriptions(NodeId).
get_subscription(_NodeId, _Owner) ->
{result, []}.
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
node_hometree:set_subscription(NodeId, Owner, Subscription).
get_states(NodeId) ->
node_default:get_states(NodeId).
node_hometree:get_states(NodeId).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
node_hometree:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
node_hometree:set_state(State).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
node_hometree:get_items(NodeId, From).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
node_hometree:get_item(NodeId, ItemId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).
node_hometree:set_item(Item).
get_item_name(Host, Node, Id) ->
node_default:get_item_name(Host, Node, Id).
node_hometree:get_item_name(Host, Node, Id).

View File

@ -64,10 +64,10 @@
init(Host, ServerHost, Opts) ->
node_default:init(Host, ServerHost, Opts).
node_hometree:init(Host, ServerHost, Opts).
terminate(Host, ServerHost) ->
node_default:terminate(Host, ServerHost).
node_hometree:terminate(Host, ServerHost).
options() ->
[{node_type, flat},
@ -87,9 +87,9 @@ options() ->
{presence_based_delivery, false}].
features() ->
node_default:features().
node_hometree:features().
%% use same code as node_default, but do not limite node to
%% use same code as node_hometree, but do not limite node to
%% the home/localhost/user/... hierarchy
%% any node is allowed
create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
@ -104,76 +104,76 @@ create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
{result, Allowed}.
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
node_hometree:create_node(NodeId, Owner).
delete_node(Removed) ->
node_default:delete_node(Removed).
node_hometree:delete_node(Removed).
subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
node_hometree:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
node_hometree:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
node_hometree:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
node_hometree:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(NodeId, Publisher, PublishModel, ItemId) ->
node_default:delete_item(NodeId, Publisher, PublishModel, ItemId).
node_hometree:delete_item(NodeId, Publisher, PublishModel, ItemId).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
node_hometree:purge_node(NodeId, Owner).
get_entity_affiliations(Host, Owner) ->
node_default:get_entity_affiliations(Host, Owner).
node_hometree:get_entity_affiliations(Host, Owner).
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
node_hometree:get_node_affiliations(NodeId).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
node_hometree:get_affiliation(NodeId, Owner).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
node_hometree:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) ->
node_default:get_entity_subscriptions(Host, Owner).
node_hometree:get_entity_subscriptions(Host, Owner).
get_node_subscriptions(NodeId) ->
node_default:get_node_subscriptions(NodeId).
node_hometree:get_node_subscriptions(NodeId).
get_subscription(NodeId, Owner) ->
node_default:get_subscription(NodeId, Owner).
node_hometree:get_subscription(NodeId, Owner).
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
node_hometree:set_subscription(NodeId, Owner, Subscription).
get_states(NodeId) ->
node_default:get_states(NodeId).
node_hometree:get_states(NodeId).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
node_hometree:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
node_hometree:set_state(State).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
node_hometree:get_items(NodeId, From).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
node_hometree:get_item(NodeId, ItemId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).
node_hometree:set_item(Item).
get_item_name(Host, Node, Id) ->
node_default:get_item_name(Host, Node, Id).
node_hometree:get_item_name(Host, Node, Id).

View File

@ -38,7 +38,7 @@
%%% useable and useful as is. Please, send us comments, feedback and
%%% improvements.</p>
-module(node_default).
-module(node_hometree).
-author('christophe.romain@process-one.net').
-include_lib("exmpp/include/exmpp.hrl").
@ -804,7 +804,7 @@ del_items(NodeId, ItemIds) ->
%% @doc <p>Return the name of the node if known: Default is to return
%% node id.</p>
get_item_name(_host, _Node, Id) ->
get_item_name(_Host, _Node, Id) ->
Id.
%% @spec (Affiliation, Subscription) -> true | false

View File

@ -121,7 +121,7 @@ create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_pep:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
create_node(NodeId, Owner) ->
node_pep:create_node(NodeId, Owner).
node_pep:create_node(NodeId, Owner).
delete_node(Removed) ->
node_pep:delete_node(Removed).
@ -151,13 +151,13 @@ get_entity_affiliations(Host, Owner) ->
node_pep:get_entity_affiliations(Host, Owner).
get_node_affiliations(NodeId) ->
node_pep:get_node_affiliations(NodeId).
node_pep:get_node_affiliations(NodeId).
get_affiliation(NodeId, Owner) ->
node_pep:get_affiliation(NodeId, Owner).
set_affiliation(NodeId, Owner, Affiliation) ->
node_pep:set_affiliation(NodeId, Owner, Affiliation).
node_pep:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) ->
node_pep:get_entity_subscriptions(Host, Owner).

View File

@ -68,12 +68,12 @@
]).
init(Host, ServerHost, Opts) ->
node_default:init(Host, ServerHost, Opts),
node_hometree:init(Host, ServerHost, Opts),
complain_if_modcaps_disabled(ServerHost),
ok.
terminate(Host, ServerHost) ->
node_default:terminate(Host, ServerHost),
node_hometree:terminate(Host, ServerHost),
ok.
options() ->
@ -134,40 +134,40 @@ create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
{result, Allowed}.
create_node(NodeId, Owner) ->
case node_default:create_node(NodeId, Owner) of
case node_hometree:create_node(NodeId, Owner) of
{result, _} -> {result, []};
Error -> Error
end.
delete_node(Removed) ->
case node_default:delete_node(Removed) of
case node_hometree:delete_node(Removed) of
{result, {_, _, Removed}} -> {result, {[], Removed}};
Error -> Error
end.
subscribe_node(NodeId, Sender, Subscriber, AccessModel,
SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(
node_hometree:subscribe_node(
NodeId, Sender, Subscriber, AccessModel, SendLast,
PresenceSubscription, RosterGroup).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
case node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID) of
case node_hometree:unsubscribe_node(NodeId, Sender, Subscriber, SubID) of
{error, Error} -> {error, Error};
{result, _} -> {result, []}
end.
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
node_hometree:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
node_hometree:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(NodeId, Publisher, PublishModel, ItemId) ->
node_default:delete_item(NodeId, Publisher, PublishModel, ItemId).
node_hometree:delete_item(NodeId, Publisher, PublishModel, ItemId).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
node_hometree:purge_node(NodeId, Owner).
get_entity_affiliations(_Host, Owner) ->
{_, D, _} = SubKey = jlib:jid_tolower(Owner),
@ -187,13 +187,13 @@ get_entity_affiliations(_Host, Owner) ->
{result, Reply}.
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
node_hometree:get_node_affiliations(NodeId).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
node_hometree:get_affiliation(NodeId, Owner).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
node_hometree:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(_Host, Owner) ->
{U, D, _} = SubKey = jlib:jid_tolower(Owner),
@ -224,40 +224,40 @@ get_node_subscriptions(NodeId) ->
%% but that call returns also all subscription to none
%% and this is required for broadcast to occurs
%% DO NOT REMOVE
node_default:get_node_subscriptions(NodeId).
node_hometree:get_node_subscriptions(NodeId).
get_subscription(NodeId, Owner) ->
node_default:get_subscription(NodeId, Owner).
node_hometree:get_subscription(NodeId, Owner).
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
node_hometree:set_subscription(NodeId, Owner, Subscription).
get_states(NodeId) ->
node_default:get_states(NodeId).
node_hometree:get_states(NodeId).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
node_hometree:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
node_hometree:set_state(State).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
node_hometree:get_items(NodeId, From).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
node_hometree:get_item(NodeId, ItemId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).
node_hometree:set_item(Item).
get_item_name(Host, Node, Id) ->
node_default:get_item_name(Host, Node, Id).
node_hometree:get_item_name(Host, Node, Id).
%%%

View File

@ -37,7 +37,7 @@
%% it's possible not to define some function at all
%% in that case, warning will be generated at compilation
%% and function call will fail,
%% then mod_pubsub will call function from node_default
%% then mod_pubsub will call function from node_hometree
%% (this makes code cleaner, but execution a little bit longer)
%% API definition
@ -73,10 +73,10 @@
init(Host, ServerHost, Opts) ->
node_default:init(Host, ServerHost, Opts).
node_hometree:init(Host, ServerHost, Opts).
terminate(Host, ServerHost) ->
node_default:terminate(Host, ServerHost).
node_hometree:terminate(Host, ServerHost).
options() ->
[{node_type, private},
@ -113,82 +113,82 @@ features() ->
].
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_default:create_node_permission(Host, ServerHost, Node, ParentNode,
node_hometree:create_node_permission(Host, ServerHost, Node, ParentNode,
Owner, Access).
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
node_hometree:create_node(NodeId, Owner).
delete_node(Removed) ->
node_default:delete_node(Removed).
node_hometree:delete_node(Removed).
subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast,
PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(NodeId, Sender, Subscriber, AccessModel,
node_hometree:subscribe_node(NodeId, Sender, Subscriber, AccessModel,
SendLast, PresenceSubscription, RosterGroup).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
node_hometree:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
node_hometree:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
node_hometree:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(NodeId, Publisher, PublishModel, ItemId) ->
node_default:delete_item(NodeId, Publisher, PublishModel, ItemId).
node_hometree:delete_item(NodeId, Publisher, PublishModel, ItemId).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
node_hometree:purge_node(NodeId, Owner).
get_entity_affiliations(Host, Owner) ->
node_default:get_entity_affiliations(Host, Owner).
node_hometree:get_entity_affiliations(Host, Owner).
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
node_hometree:get_node_affiliations(NodeId).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
node_hometree:get_affiliation(NodeId, Owner).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
node_hometree:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) ->
node_default:get_entity_subscriptions(Host, Owner).
node_hometree:get_entity_subscriptions(Host, Owner).
get_node_subscriptions(NodeId) ->
node_default:get_node_subscriptions(NodeId).
node_hometree:get_node_subscriptions(NodeId).
get_subscription(NodeId, Owner) ->
node_default:get_subscription(NodeId, Owner).
node_hometree:get_subscription(NodeId, Owner).
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
node_hometree:set_subscription(NodeId, Owner, Subscription).
get_states(NodeId) ->
node_default:get_states(NodeId).
node_hometree:get_states(NodeId).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
node_hometree:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
node_hometree:set_state(State).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
node_hometree:get_items(NodeId, From).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
node_hometree:get_item(NodeId, ItemId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).
node_hometree:set_item(Item).
get_item_name(Host, Node, Id) ->
node_default:get_item_name(Host, Node, Id).
node_hometree:get_item_name(Host, Node, Id).

View File

@ -37,7 +37,7 @@
%% it's possible not to define some function at all
%% in that case, warning will be generated at compilation
%% and function call will fail,
%% then mod_pubsub will call function from node_default
%% then mod_pubsub will call function from node_hometree
%% (this makes code cleaner, but execution a little bit longer)
%% API definition
@ -73,10 +73,10 @@
init(Host, ServerHost, Opts) ->
node_default:init(Host, ServerHost, Opts).
node_hometree:init(Host, ServerHost, Opts).
terminate(Host, ServerHost) ->
node_default:terminate(Host, ServerHost).
node_hometree:terminate(Host, ServerHost).
options() ->
[{node_type, public},
@ -113,81 +113,81 @@ features() ->
].
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_default:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
node_hometree:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
node_hometree:create_node(NodeId, Owner).
delete_node(Removed) ->
node_default:delete_node(Removed).
node_hometree:delete_node(Removed).
subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
node_hometree:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
node_hometree:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
node_hometree:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
node_hometree:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(NodeId, Publisher, PublishModel, ItemId) ->
node_default:delete_item(NodeId, Publisher, PublishModel, ItemId).
node_hometree:delete_item(NodeId, Publisher, PublishModel, ItemId).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
node_hometree:purge_node(NodeId, Owner).
get_entity_affiliations(Host, Owner) ->
node_default:get_entity_affiliations(Host, Owner).
node_hometree:get_entity_affiliations(Host, Owner).
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
node_hometree:get_node_affiliations(NodeId).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
node_hometree:get_affiliation(NodeId, Owner).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
node_hometree:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) ->
node_default:get_entity_subscriptions(Host, Owner).
node_hometree:get_entity_subscriptions(Host, Owner).
get_node_subscriptions(NodeId) ->
node_default:get_node_subscriptions(NodeId).
node_hometree:get_node_subscriptions(NodeId).
get_subscription(NodeId, Owner) ->
node_default:get_subscription(NodeId, Owner).
node_hometree:get_subscription(NodeId, Owner).
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
node_hometree:set_subscription(NodeId, Owner, Subscription).
get_states(NodeId) ->
node_default:get_states(NodeId).
node_hometree:get_states(NodeId).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
node_hometree:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
node_hometree:set_state(State).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
node_hometree:get_items(NodeId, From).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
node_hometree:get_item(NodeId, ItemId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
node_hometree:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).
node_hometree:set_item(Item).
%% @doc <p>Return the name of the node if known: Default is to return
%% node id.</p>
get_item_name(Host, Node, Id) ->
node_default:get_item_name(Host, Node, Id).
node_hometree:get_item_name(Host, Node, Id).

View File

@ -33,7 +33,7 @@
%%% useable and useful as is. Please, send us comments, feedback and
%%% improvements.</p>
-module(nodetree_default).
-module(nodetree_tree).
-author('christophe.romain@process-one.net').
-include_lib("exmpp/include/exmpp.hrl").
@ -141,7 +141,7 @@ get_subnodes(Host, Node) ->
get_subnodes_tree(Host, Node, _From) ->
get_subnodes_tree(Host, Node).
get_subnodes_tree(Host, Node) ->
mnesia:foldl(fun(#pubsub_node{nodeid = {H, N} = R}, Acc) ->
mnesia:foldl(fun(#pubsub_node{nodeid = {H, N}} = R, Acc) ->
case lists:prefix(Node, N) and (H == Host) of
true -> [R | Acc];
_ -> Acc