25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

* src/mod_pubsub/mod_pubsub.erl: Added the from field in the

get_subnodes pubsub plugin API function. This is usefull to write
plugins to generate the pubsub hierarchy dynamically, based on who
is doing the browsing request.
* src/mod_pubsub/gen_pubsub_nodetree.erl: Likewise
* src/mod_pubsub/nodetree_default.erl: Likewise
* src/mod_pubsub/nodetree_virtual.erl: Likewise

SVN Revision: 1168
This commit is contained in:
Mickaël Rémond 2008-02-02 14:15:37 +00:00
parent fb6c0d4771
commit fff45aca21
5 changed files with 25 additions and 13 deletions

View File

@ -1,3 +1,13 @@
2008-02-02 Mickael Remond <mremond@process-one.net>
* src/mod_pubsub/mod_pubsub.erl: Added the from field in the
get_subnodes pubsub plugin API function. This is usefull to write
plugins to generate the pubsub hierarchy dynamically, based on who
is doing the browsing request.
* src/mod_pubsub/gen_pubsub_nodetree.erl: Likewise
* src/mod_pubsub/nodetree_default.erl: Likewise
* src/mod_pubsub/nodetree_virtual.erl: Likewise
2008-01-30 Badlop <badlop@process-one.net> 2008-01-30 Badlop <badlop@process-one.net>
* doc/guide.tex: Removed the option served_hosts in mod_pubsub * doc/guide.tex: Removed the option served_hosts in mod_pubsub

View File

@ -44,7 +44,7 @@ behaviour_info(callbacks) ->
{set_node, 1}, {set_node, 1},
{get_node, 2}, {get_node, 2},
{get_nodes, 1}, {get_nodes, 1},
{get_subnodes, 2}, {get_subnodes, 3},
{get_subnodes_tree, 2}, {get_subnodes_tree, 2},
{create_node, 5}, {create_node, 5},
{delete_node, 2} {delete_node, 2}

View File

@ -685,7 +685,7 @@ node_disco_identity(Host, Node, From) ->
node_disco_info(Host, Node, From, true, false). node_disco_info(Host, Node, From, true, false).
node_disco_features(Host, Node, From) -> node_disco_features(Host, Node, From) ->
node_disco_info(Host, Node, From, false, true). node_disco_info(Host, Node, From, false, true).
node_disco_info(Host, Node, _From, Identity, Features) -> node_disco_info(Host, Node, From, Identity, Features) ->
Action = Action =
fun(#pubsub_node{type = Type}) -> fun(#pubsub_node{type = Type}) ->
I = case Identity of I = case Identity of
@ -693,7 +693,7 @@ node_disco_info(Host, Node, _From, Identity, Features) ->
[]; [];
true -> true ->
Types = Types =
case tree_call(Host, get_subnodes, [Host, Node]) of case tree_call(Host, get_subnodes, [Host, Node, From]) of
[] -> [] ->
["leaf"]; %% No sub-nodes: it's a leaf node ["leaf"]; %% No sub-nodes: it's a leaf node
_ -> _ ->
@ -740,7 +740,7 @@ iq_disco_info(Host, SNode, From, Lang) ->
node_disco_info(Host, Node, From) node_disco_info(Host, Node, From)
end. end.
iq_disco_items(Host, [], _From) -> iq_disco_items(Host, [], From) ->
{result, lists:map( {result, lists:map(
fun(#pubsub_node{nodeid = {_, SubNode}}) -> fun(#pubsub_node{nodeid = {_, SubNode}}) ->
SN = node_to_string(SubNode), SN = node_to_string(SubNode),
@ -749,8 +749,8 @@ iq_disco_items(Host, [], _From) ->
{xmlelement, "item", [{"jid", Host}, {xmlelement, "item", [{"jid", Host},
{"node", SN}, {"node", SN},
{"name", RN}], []} {"name", RN}], []}
end, tree_action(Host, get_subnodes, [Host, []]))}; end, tree_action(Host, get_subnodes, [Host, [], From]))};
iq_disco_items(Host, Item, _From) -> iq_disco_items(Host, Item, From) ->
case string:tokens(Item, "!") of case string:tokens(Item, "!") of
[_SNode, _ItemID] -> [_SNode, _ItemID] ->
{result, []}; {result, []};
@ -771,7 +771,7 @@ iq_disco_items(Host, Item, _From) ->
SN = node_to_string(SubNode), SN = node_to_string(SubNode),
RN = lists:last(SubNode), RN = lists:last(SubNode),
{xmlelement, "item", [{"jid", Host}, {"node", SN}, {"name", RN}], []} {xmlelement, "item", [{"jid", Host}, {"node", SN}, {"name", RN}], []}
end, tree_call(Host, get_subnodes, [Host, Node])), end, tree_call(Host, get_subnodes, [Host, Node, From])),
Items = lists:map( Items = lists:map(
fun(#pubsub_item{itemid = {RN, _}}) -> fun(#pubsub_item{itemid = {RN, _}}) ->
SN = node_to_string(Node) ++ "!" ++ RN, SN = node_to_string(Node) ++ "!" ++ RN,

View File

@ -47,7 +47,7 @@
set_node/1, set_node/1,
get_node/2, get_node/2,
get_nodes/1, get_nodes/1,
get_subnodes/2, get_subnodes/3,
get_subnodes_tree/2, get_subnodes_tree/2,
create_node/5, create_node/5,
delete_node/2 delete_node/2
@ -109,10 +109,11 @@ get_node(Host, Node) ->
get_nodes(Key) -> get_nodes(Key) ->
mnesia:match_object(#pubsub_node{nodeid = {Key, '_'}, _ = '_'}). mnesia:match_object(#pubsub_node{nodeid = {Key, '_'}, _ = '_'}).
%% @spec (Host, Index) -> [pubsubNode()] | {error, Reason} %% @spec (Host, Node, From) -> [pubsubNode()] | {error, Reason}
%% Host = mod_pubsub:host() %% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode() %% Node = mod_pubsub:pubsubNode()
get_subnodes(Host, Node) -> %% From = mod_pubsub:jid()
get_subnodes(Host, Node, _From) ->
mnesia:index_read(pubsub_node, {Host, Node}, #pubsub_node.parentid). mnesia:index_read(pubsub_node, {Host, Node}, #pubsub_node.parentid).
%% @spec (Host, Index) -> [pubsubNode()] | {error, Reason} %% @spec (Host, Index) -> [pubsubNode()] | {error, Reason}

View File

@ -45,7 +45,7 @@
set_node/1, set_node/1,
get_node/2, get_node/2,
get_nodes/1, get_nodes/1,
get_subnodes/2, get_subnodes/3,
get_subnodes_tree/2, get_subnodes_tree/2,
create_node/5, create_node/5,
delete_node/2 delete_node/2
@ -96,11 +96,12 @@ get_node(Host, Node) ->
get_nodes(_Key) -> get_nodes(_Key) ->
[]. [].
%% @spec (Host, Index) -> [pubsubNode()] %% @spec (Host, Node, From) -> [pubsubNode()]
%% Host = mod_pubsub:host() %% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode() %% Node = mod_pubsub:pubsubNode()
%% From = mod_pubsub:jid()
%% @doc <p>Virtual node tree does not handle parent/child. Child list is empty.</p> %% @doc <p>Virtual node tree does not handle parent/child. Child list is empty.</p>
get_subnodes(_Host, _Node) -> get_subnodes(_Host, _Node, _From) ->
[]. [].
%% @spec (Host, Index) -> [pubsubNode()] %% @spec (Host, Index) -> [pubsubNode()]