diff --git a/ChangeLog b/ChangeLog index 6f18c6db4..bbfe1a614 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-02-02 Mickael Remond + + * 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 * doc/guide.tex: Removed the option served_hosts in mod_pubsub diff --git a/src/mod_pubsub/gen_pubsub_nodetree.erl b/src/mod_pubsub/gen_pubsub_nodetree.erl index c284244ac..668b71a8e 100644 --- a/src/mod_pubsub/gen_pubsub_nodetree.erl +++ b/src/mod_pubsub/gen_pubsub_nodetree.erl @@ -44,7 +44,7 @@ behaviour_info(callbacks) -> {set_node, 1}, {get_node, 2}, {get_nodes, 1}, - {get_subnodes, 2}, + {get_subnodes, 3}, {get_subnodes_tree, 2}, {create_node, 5}, {delete_node, 2} diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl index 12ea98cba..b03b560de 100644 --- a/src/mod_pubsub/mod_pubsub.erl +++ b/src/mod_pubsub/mod_pubsub.erl @@ -685,7 +685,7 @@ node_disco_identity(Host, Node, From) -> node_disco_info(Host, Node, From, true, false). node_disco_features(Host, Node, From) -> 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 = fun(#pubsub_node{type = Type}) -> I = case Identity of @@ -693,7 +693,7 @@ node_disco_info(Host, Node, _From, Identity, Features) -> []; true -> 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 _ -> @@ -740,7 +740,7 @@ iq_disco_info(Host, SNode, From, Lang) -> node_disco_info(Host, Node, From) end. -iq_disco_items(Host, [], _From) -> +iq_disco_items(Host, [], From) -> {result, lists:map( fun(#pubsub_node{nodeid = {_, SubNode}}) -> SN = node_to_string(SubNode), @@ -749,8 +749,8 @@ iq_disco_items(Host, [], _From) -> {xmlelement, "item", [{"jid", Host}, {"node", SN}, {"name", RN}], []} - end, tree_action(Host, get_subnodes, [Host, []]))}; -iq_disco_items(Host, Item, _From) -> + end, tree_action(Host, get_subnodes, [Host, [], From]))}; +iq_disco_items(Host, Item, From) -> case string:tokens(Item, "!") of [_SNode, _ItemID] -> {result, []}; @@ -771,7 +771,7 @@ iq_disco_items(Host, Item, _From) -> SN = node_to_string(SubNode), RN = lists:last(SubNode), {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( fun(#pubsub_item{itemid = {RN, _}}) -> SN = node_to_string(Node) ++ "!" ++ RN, diff --git a/src/mod_pubsub/nodetree_default.erl b/src/mod_pubsub/nodetree_default.erl index 3d98dd07c..80eeefb31 100644 --- a/src/mod_pubsub/nodetree_default.erl +++ b/src/mod_pubsub/nodetree_default.erl @@ -47,7 +47,7 @@ set_node/1, get_node/2, get_nodes/1, - get_subnodes/2, + get_subnodes/3, get_subnodes_tree/2, create_node/5, delete_node/2 @@ -109,10 +109,11 @@ get_node(Host, Node) -> get_nodes(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() %% 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). %% @spec (Host, Index) -> [pubsubNode()] | {error, Reason} diff --git a/src/mod_pubsub/nodetree_virtual.erl b/src/mod_pubsub/nodetree_virtual.erl index 5bd5b5dea..e532d290a 100644 --- a/src/mod_pubsub/nodetree_virtual.erl +++ b/src/mod_pubsub/nodetree_virtual.erl @@ -45,7 +45,7 @@ set_node/1, get_node/2, get_nodes/1, - get_subnodes/2, + get_subnodes/3, get_subnodes_tree/2, create_node/5, delete_node/2 @@ -96,11 +96,12 @@ get_node(Host, Node) -> get_nodes(_Key) -> []. -%% @spec (Host, Index) -> [pubsubNode()] +%% @spec (Host, Node, From) -> [pubsubNode()] %% Host = mod_pubsub:host() %% Node = mod_pubsub:pubsubNode() +%% From = mod_pubsub:jid() %% @doc

Virtual node tree does not handle parent/child. Child list is empty.

-get_subnodes(_Host, _Node) -> +get_subnodes(_Host, _Node, _From) -> []. %% @spec (Host, Index) -> [pubsubNode()]