25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

PubSub/PEP API change for major optimization

SVN Revision: 2048
This commit is contained in:
Christophe Romain 2009-04-30 05:18:06 +00:00
parent b2659e4a6f
commit f8780bc6ee
18 changed files with 1325 additions and 1159 deletions

View File

@ -1,3 +1,22 @@
2009-04-24 Christophe Romain <christophe.romain@process-one.net>
* src/mod_pubsub/mod_pubsub.erl: API change for major optimization
* src/mod_pubsub/pubsub.hrl: Likewise
* src/mod_pubsub/nodetree_default.erl: Likewise
* src/mod_pubsub/nodetree_virtual.erl: Likewise
* src/mod_pubsub/node_mb.erl: Likewise
* src/mod_pubsub/node_dispatch.erl: Likewise
* src/mod_pubsub/node_buddy.erl: Likewise
* src/mod_pubsub/node_private.erl: Likewise
* src/mod_pubsub/node_public.erl: Likewise
* src/mod_pubsub/node_default.erl: Likewise
* src/mod_pubsub/node_pep.erl: Likewise
* src/mod_pubsub/node_club.erl: Likewise
* src/mod_pubsub/node_flat.erl: Likewise
* src/mod_pubsub/node.template: Likewise
* src/mod_pubsub/gen_pubsub_node.erl: Likewise
* src/mod_pubsub/gen_pubsub_nodetree.erl: Likewise
2009-04-28 Badlop <badlop@process-one.net>
* src/ejabberd_hooks.erl: Support distributed hooks (EJAB-829)

View File

@ -43,29 +43,29 @@ behaviour_info(callbacks) ->
{options, 0},
{features, 0},
{create_node_permission, 6},
{create_node, 3},
{delete_node, 2},
{purge_node, 3},
{subscribe_node, 8},
{unsubscribe_node, 5},
{publish_item, 7},
{delete_item, 4},
{remove_extra_items, 4},
{get_node_affiliations, 2},
{create_node, 2},
{delete_node, 1},
{purge_node, 2},
{subscribe_node, 7},
{unsubscribe_node, 4},
{publish_item, 6},
{delete_item, 3},
{remove_extra_items, 3},
{get_node_affiliations, 1},
{get_entity_affiliations, 2},
{get_affiliation, 3},
{set_affiliation, 4},
{get_node_subscriptions, 2},
{get_affiliation, 2},
{set_affiliation, 3},
{get_node_subscriptions, 1},
{get_entity_subscriptions, 2},
{get_subscription, 3},
{set_subscription, 4},
{get_states, 2},
{get_state, 3},
{get_subscription, 2},
{set_subscription, 3},
{get_states, 1},
{get_state, 2},
{set_state, 1},
{get_items, 7},
{get_items, 3},
{get_item, 8},
{get_item, 3},
{get_items, 6},
{get_items, 2},
{get_item, 7},
{get_item, 2},
{set_item, 1},
{get_item_name, 3}
];

View File

@ -47,7 +47,7 @@ behaviour_info(callbacks) ->
{get_nodes, 2},
{get_nodes, 1},
{get_subnodes, 3},
{get_subnodes_tree, 2},
{get_subnodes_tree, 3},
{create_node, 5},
{delete_node, 2}
];

File diff suppressed because it is too large Load Diff

View File

@ -42,29 +42,29 @@
-export([init/3, terminate/2,
options/0, features/0,
create_node_permission/6,
create_node/3,
delete_node/2,
purge_node/3,
subscribe_node/8,
unsubscribe_node/5,
publish_item/7,
delete_item/4,
remove_extra_items/4,
create_node/2,
delete_node/1,
purge_node/2,
subscribe_node/7,
unsubscribe_node/4,
publish_item/6,
delete_item/3,
remove_extra_items/3,
get_entity_affiliations/2,
get_node_affiliations/2,
get_affiliation/3,
set_affiliation/4,
get_node_affiliations/1,
get_affiliation/2,
set_affiliation/3,
get_entity_subscriptions/2,
get_node_subscriptions/2,
get_subscription/3,
set_subscription/4,
get_states/2,
get_state/3,
get_node_subscriptions/1,
get_subscription/2,
set_subscription/3,
get_states/1,
get_state/2,
set_state/1,
get_items/7,
get_items/3,
get_item/8,
get_item/3,
get_items/6,
get_items/2,
get_item/7,
get_item/2,
set_item/1
]).
@ -88,7 +88,7 @@ options() ->
{roster_groups_allowed, []},
{publish_model, publishers},
{max_payload_size, ?MAX_PAYLOAD_SIZE},
{send_last_published_item, never},
{send_last_published_item, on_sub_and_presence},
{deliver_notifications, true},
{presence_based_delivery, false}].
@ -112,74 +112,74 @@ features() ->
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_default:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
create_node(Host, Node, Owner) ->
node_default:create_node(Host, Node, Owner).
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
delete_node(Host, Removed) ->
node_default:delete_node(Host, Removed).
delete_node(Removed) ->
node_default:delete_node(Removed).
subscribe_node(Host, Node, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(Host, Node, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
unsubscribe_node(Host, Node, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(Host, Node, Sender, Subscriber, SubID).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(Host, Node, MaxItems, ItemIds) ->
node_default:remove_extra_items(Host, Node, MaxItems, ItemIds).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(Host, Node, JID, ItemId) ->
node_default:delete_item(Host, Node, JID, ItemId).
delete_item(NodeId, JID, ItemId) ->
node_default:delete_item(NodeId, JID, ItemId).
purge_node(Host, Node, Owner) ->
node_default:purge_node(Host, Node, Owner).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
get_entity_affiliations(Host, Owner) ->
node_default:get_entity_affiliations(Host, Owner).
get_node_affiliations(Host, Node) ->
node_default:get_node_affiliations(Host, Node).
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
get_affiliation(Host, Node, Owner) ->
node_default:get_affiliation(Host, Node, Owner).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
set_affiliation(Host, Node, Owner, Affiliation) ->
node_default:set_affiliation(Host, Node, Owner, Affiliation).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) ->
node_default:get_entity_subscriptions(Host, Owner).
get_node_subscriptions(Host, Node) ->
node_default:get_node_subscriptions(Host, Node).
get_node_subscriptions(NodeId) ->
node_default:get_node_subscriptions(NodeId).
get_subscription(Host, Node, Owner) ->
node_default:get_subscription(Host, Node, Owner).
get_subscription(NodeId, Owner) ->
node_default:get_subscription(NodeId, Owner).
set_subscription(Host, Node, Owner, Subscription) ->
node_default:set_subscription(Host, Node, Owner, Subscription).
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
get_states(Host, Node) ->
node_default:get_states(Host, Node).
get_states(NodeId) ->
node_default:get_states(NodeId).
get_state(Host, Node, JID) ->
node_default:get_state(Host, Node, JID).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
get_items(Host, Node, From) ->
node_default:get_items(Host, Node, From).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId)
node_default:get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId)
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(Host, Node, ItemId) ->
node_default:get_item(Host, Node, ItemId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).

View File

@ -43,29 +43,29 @@
-export([init/3, terminate/2,
options/0, features/0,
create_node_permission/6,
create_node/3,
delete_node/2,
purge_node/3,
subscribe_node/8,
unsubscribe_node/5,
publish_item/7,
delete_item/4,
remove_extra_items/4,
create_node/2,
delete_node/1,
purge_node/2,
subscribe_node/7,
unsubscribe_node/4,
publish_item/6,
delete_item/3,
remove_extra_items/3,
get_entity_affiliations/2,
get_node_affiliations/2,
get_affiliation/3,
set_affiliation/4,
get_node_affiliations/1,
get_affiliation/2,
set_affiliation/3,
get_entity_subscriptions/2,
get_node_subscriptions/2,
get_subscription/3,
set_subscription/4,
get_states/2,
get_state/3,
get_node_subscriptions/1,
get_subscription/2,
set_subscription/3,
get_states/1,
get_state/2,
set_state/1,
get_items/7,
get_items/3,
get_item/8,
get_item/3,
get_items/6,
get_items/2,
get_item/7,
get_item/2,
set_item/1,
get_item_name/3
]).
@ -115,74 +115,74 @@ features() ->
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_default:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
create_node(Host, Node, Owner) ->
node_default:create_node(Host, Node, Owner).
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
delete_node(Host, Removed) ->
node_default:delete_node(Host, Removed).
delete_node(Removed) ->
node_default:delete_node(Removed).
subscribe_node(Host, Node, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(Host, Node, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
unsubscribe_node(Host, Node, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(Host, Node, Sender, Subscriber, SubID).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(Host, Node, MaxItems, ItemIds) ->
node_default:remove_extra_items(Host, Node, MaxItems, ItemIds).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(Host, Node, JID, ItemId) ->
node_default:delete_item(Host, Node, JID, ItemId).
delete_item(NodeId, JID, ItemId) ->
node_default:delete_item(NodeId, JID, ItemId).
purge_node(Host, Node, Owner) ->
node_default:purge_node(Host, Node, Owner).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
get_entity_affiliations(Host, Owner) ->
node_default:get_entity_affiliations(Host, Owner).
get_node_affiliations(Host, Node) ->
node_default:get_node_affiliations(Host, Node).
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
get_affiliation(Host, Node, Owner) ->
node_default:get_affiliation(Host, Node, Owner).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
set_affiliation(Host, Node, Owner, Affiliation) ->
node_default:set_affiliation(Host, Node, Owner, Affiliation).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) ->
node_default:get_entity_subscriptions(Host, Owner).
get_node_subscriptions(Host, Node) ->
node_default:get_node_subscriptions(Host, Node).
get_node_subscriptions(NodeId) ->
node_default:get_node_subscriptions(NodeId).
get_subscription(Host, Node, Owner) ->
node_default:get_subscription(Host, Node, Owner).
get_subscription(NodeId, Owner) ->
node_default:get_subscription(NodeId, Owner).
set_subscription(Host, Node, Owner, Subscription) ->
node_default:set_subscription(Host, Node, Owner, Subscription).
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
get_states(Host, Node) ->
node_default:get_states(Host, Node).
get_states(NodeId) ->
node_default:get_states(NodeId).
get_state(Host, Node, JID) ->
node_default:get_state(Host, Node, JID).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
get_items(Host, Node, From) ->
node_default:get_items(Host, Node, From).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(Host, Node, ItemId) ->
node_default:get_item(Host, Node, ItemId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).

View File

@ -43,29 +43,29 @@
-export([init/3, terminate/2,
options/0, features/0,
create_node_permission/6,
create_node/3,
delete_node/2,
purge_node/3,
subscribe_node/8,
unsubscribe_node/5,
publish_item/7,
delete_item/4,
remove_extra_items/4,
create_node/2,
delete_node/1,
purge_node/2,
subscribe_node/7,
unsubscribe_node/4,
publish_item/6,
delete_item/3,
remove_extra_items/3,
get_entity_affiliations/2,
get_node_affiliations/2,
get_affiliation/3,
set_affiliation/4,
get_node_affiliations/1,
get_affiliation/2,
set_affiliation/3,
get_entity_subscriptions/2,
get_node_subscriptions/2,
get_subscription/3,
set_subscription/4,
get_states/2,
get_state/3,
get_node_subscriptions/1,
get_subscription/2,
set_subscription/3,
get_states/1,
get_state/2,
set_state/1,
get_items/7,
get_items/3,
get_item/8,
get_item/3,
get_items/6,
get_items/2,
get_item/7,
get_item/2,
set_item/1,
get_item_name/3
]).
@ -114,74 +114,74 @@ features() ->
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_default:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
create_node(Host, Node, Owner) ->
node_default:create_node(Host, Node, Owner).
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
delete_node(Host, Removed) ->
node_default:delete_node(Host, Removed).
delete_node(Removed) ->
node_default:delete_node(Removed).
subscribe_node(Host, Node, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(Host, Node, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
unsubscribe_node(Host, Node, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(Host, Node, Sender, Subscriber, SubID).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(Host, Node, MaxItems, ItemIds) ->
node_default:remove_extra_items(Host, Node, MaxItems, ItemIds).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(Host, Node, JID, ItemId) ->
node_default:delete_item(Host, Node, JID, ItemId).
delete_item(NodeId, JID, ItemId) ->
node_default:delete_item(NodeId, JID, ItemId).
purge_node(Host, Node, Owner) ->
node_default:purge_node(Host, Node, Owner).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
get_entity_affiliations(Host, Owner) ->
node_default:get_entity_affiliations(Host, Owner).
get_node_affiliations(Host, Node) ->
node_default:get_node_affiliations(Host, Node).
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
get_affiliation(Host, Node, Owner) ->
node_default:get_affiliation(Host, Node, Owner).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
set_affiliation(Host, Node, Owner, Affiliation) ->
node_default:set_affiliation(Host, Node, Owner, Affiliation).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) ->
node_default:get_entity_subscriptions(Host, Owner).
get_node_subscriptions(Host, Node) ->
node_default:get_node_subscriptions(Host, Node).
get_node_subscriptions(NodeId) ->
node_default:get_node_subscriptions(NodeId).
get_subscription(Host, Node, Owner) ->
node_default:get_subscription(Host, Node, Owner).
get_subscription(NodeId, Owner) ->
node_default:get_subscription(NodeId, Owner).
set_subscription(Host, Node, Owner, Subscription) ->
node_default:set_subscription(Host, Node, Owner, Subscription).
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
get_states(Host, Node) ->
node_default:get_states(Host, Node).
get_states(NodeId) ->
node_default:get_states(NodeId).
get_state(Host, Node, JID) ->
node_default:get_state(Host, Node, JID).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
get_items(Host, Node, From) ->
node_default:get_items(Host, Node, From).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(Host, Node, ItemId) ->
node_default:get_item(Host, Node, ItemId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).

View File

@ -50,29 +50,29 @@
-export([init/3, terminate/2,
options/0, features/0,
create_node_permission/6,
create_node/3,
delete_node/2,
purge_node/3,
subscribe_node/8,
unsubscribe_node/5,
publish_item/7,
delete_item/4,
remove_extra_items/4,
create_node/2,
delete_node/1,
purge_node/2,
subscribe_node/7,
unsubscribe_node/4,
publish_item/6,
delete_item/3,
remove_extra_items/3,
get_entity_affiliations/2,
get_node_affiliations/2,
get_affiliation/3,
set_affiliation/4,
get_node_affiliations/1,
get_affiliation/2,
set_affiliation/3,
get_entity_subscriptions/2,
get_node_subscriptions/2,
get_subscription/3,
set_subscription/4,
get_states/2,
get_state/3,
get_node_subscriptions/1,
get_subscription/2,
set_subscription/3,
get_states/1,
get_state/2,
set_state/1,
get_items/7,
get_items/3,
get_item/8,
get_item/3,
get_items/6,
get_items/2,
get_item/7,
get_item/2,
set_item/1,
get_item_name/3
]).
@ -192,8 +192,8 @@ features() ->
%% <p>PubSub plugins can redefine the PubSub node creation rights as they
%% which. They can simply delegate this check to the {@link node_default}
%% module by implementing this function like this:
%% ```check_create_user_permission(Host, Node, Owner, Access) ->
%% node_default:check_create_user_permission(Host, Node, Owner, Access).'''</p>
%% ```check_create_user_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
%% node_default:check_create_user_permission(Host, ServerHost, Node, ParentNode, Owner, Access).'''</p>
create_node_permission(Host, ServerHost, Node, _ParentNode, Owner, Access) ->
LOwner = jlib:jid_tolower(Owner),
{User, Server, _Resource} = LOwner,
@ -213,35 +213,36 @@ create_node_permission(Host, ServerHost, Node, _ParentNode, Owner, Access) ->
end,
{result, Allowed}.
%% @spec (Host, Node, Owner) ->
%% @spec (NodeId, Owner) ->
%% {result, Result} | exit
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% NodeId = mod_pubsub:pubsubNodeId()
%% Owner = mod_pubsub:jid()
%% @doc <p></p>
create_node(Host, Node, Owner) ->
create_node(NodeId, Owner) ->
OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
set_state(#pubsub_state{stateid = {OwnerKey, {Host, Node}}, affiliation = owner}),
set_state(#pubsub_state{stateid = {OwnerKey, NodeId}, affiliation = owner}),
{result, {default, broadcast}}.
%% @spec (Host, Removed) -> ok
%% Host = mod_pubsub:host()
%% @spec (Removed) -> ok
%% Removed = [mod_pubsub:pubsubNode()]
%% @doc <p>purge items of deleted nodes after effective deletion.</p>
delete_node(Host, Removed) ->
lists:foreach(
fun(Node) ->
lists:foreach(
fun(#pubsub_state{stateid = StateId, items = Items}) ->
del_items(Host, Node, Items),
del_state(StateId)
end,
mnesia:match_object(
#pubsub_state{stateid = {'_', {Host, Node}}, _ = '_'}))
end, Removed),
{result, {default, broadcast, Removed}}.
delete_node(Removed) ->
Tr = fun(#pubsub_state{stateid = {J, _}, subscription = S}) ->
{J, S}
end,
Reply = lists:map(
fun(#pubsub_node{id = NodeId} = PubsubNode) ->
{result, States} = get_states(NodeId),
lists:foreach(
fun(#pubsub_state{stateid = {LJID, _}, items = Items}) ->
del_items(NodeId, Items),
del_state(NodeId, LJID)
end, States),
{PubsubNode, lists:map(Tr, States)}
end, Removed),
{result, {default, broadcast, Reply}}.
%% @spec (Host, Node, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
%% @spec (NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
%% {error, Reason} | {result, Result}
%% @doc <p>Accepts or rejects subcription requests on a PubSub node.</p>
%% <p>The mechanism works as follow:
@ -274,17 +275,18 @@ delete_node(Host, Removed) ->
%% to completly disable persistance.</li></ul>
%% </p>
%% <p>In the default plugin module, the record is unchanged.</p>
subscribe_node(Host, Node, Sender, Subscriber, AccessModel,
subscribe_node(NodeId, Sender, Subscriber, AccessModel,
SendLast, PresenceSubscription, RosterGroup) ->
SubKey = jlib:jid_tolower(Subscriber),
GenKey = jlib:jid_remove_resource(SubKey),
Authorized = (jlib:jid_tolower(jlib:jid_remove_resource(Sender)) == GenKey),
GenState = get_state(Host, Node, GenKey),
GenState = get_state(NodeId, GenKey),
SubState = case SubKey of
GenKey -> GenState;
_ -> get_state(Host, Node, SubKey)
_ -> get_state(NodeId, SubKey)
end,
Affiliation = GenState#pubsub_state.affiliation,
Subscription = SubState#pubsub_state.subscription,
Whitelisted = lists:member(Affiliation, [member, publisher, owner]),
if
not Authorized ->
@ -293,7 +295,7 @@ subscribe_node(Host, Node, Sender, Subscriber, AccessModel,
Affiliation == outcast ->
%% Requesting entity is blocked
{error, ?ERR_FORBIDDEN};
SubState#pubsub_state.subscription == pending ->
Subscription == pending ->
%% Requesting entity has pending subscription
{error, ?ERR_EXTENDED(?ERR_NOT_AUTHORIZED, "pending-subscription")};
(AccessModel == presence) and (not PresenceSubscription) ->
@ -336,23 +338,22 @@ subscribe_node(Host, Node, Sender, Subscriber, AccessModel,
end
end.
%% @spec (Host, Node, Sender, Subscriber, SubID) ->
%% @spec (NodeId, Sender, Subscriber, SubID) ->
%% {error, Reason} | {result, []}
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% NodeId = mod_pubsub:pubsubNodeId()
%% Sender = mod_pubsub:jid()
%% Subscriber = mod_pubsub:jid()
%% SubID = string()
%% Reason = mod_pubsub:stanzaError()
%% @doc <p>Unsubscribe the <tt>Subscriber</tt> from the <tt>Node</tt>.</p>
unsubscribe_node(Host, Node, Sender, Subscriber, _SubId) ->
unsubscribe_node(NodeId, Sender, Subscriber, _SubId) ->
SubKey = jlib:jid_tolower(Subscriber),
GenKey = jlib:jid_remove_resource(SubKey),
Authorized = (jlib:jid_tolower(jlib:jid_remove_resource(Sender)) == GenKey),
GenState = get_state(Host, Node, GenKey),
GenState = get_state(NodeId, GenKey),
SubState = case SubKey of
GenKey -> GenState;
_ -> get_state(Host, Node, SubKey)
_ -> get_state(NodeId, SubKey)
end,
if
%% Requesting entity is prohibited from unsubscribing entity
@ -369,17 +370,16 @@ unsubscribe_node(Host, Node, Sender, Subscriber, _SubId) ->
{error, ?ERR_EXTENDED(?ERR_UNEXPECTED_REQUEST, "not-subscribed")};
%% Was just subscriber, remove the record
SubState#pubsub_state.affiliation == none ->
del_state(SubState#pubsub_state.stateid),
del_state(NodeId, SubKey),
{result, default};
true ->
set_state(SubState#pubsub_state{subscription = none}),
{result, default}
end.
%% @spec (Host, Node, Publisher, PublishModel, MaxItems, ItemId, Payload) ->
%% @spec (NodeId, Publisher, PublishModel, MaxItems, ItemId, Payload) ->
%% {true, PubsubItem} | {result, Reply}
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% NodeId = mod_pubsub:pubsubNodeId()
%% Publisher = mod_pubsub:jid()
%% PublishModel = atom()
%% MaxItems = integer()
@ -415,13 +415,13 @@ unsubscribe_node(Host, Node, Sender, Subscriber, _SubId) ->
%% to completly disable persistance.</li></ul>
%% </p>
%% <p>In the default plugin module, the record is unchanged.</p>
publish_item(Host, Node, Publisher, PublishModel, MaxItems, ItemId, Payload) ->
publish_item(NodeId, Publisher, PublishModel, MaxItems, ItemId, Payload) ->
SubKey = jlib:jid_tolower(Publisher),
GenKey = jlib:jid_remove_resource(SubKey),
GenState = get_state(Host, Node, GenKey),
GenState = get_state(NodeId, GenKey),
SubState = case SubKey of
GenKey -> GenState;
_ -> get_state(Host, Node, SubKey)
_ -> get_state(NodeId, SubKey)
end,
Affiliation = GenState#pubsub_state.affiliation,
Subscription = SubState#pubsub_state.subscription,
@ -434,31 +434,31 @@ publish_item(Host, Node, Publisher, PublishModel, MaxItems, ItemId, Payload) ->
%% Entity does not have sufficient privileges to publish to node
{error, ?ERR_FORBIDDEN};
true ->
PubId = {SubKey, now()}, %% TODO, uses {now(),PublisherKey} for sorting (EJAB-824)
%% TODO: check creation, presence, roster
Item = case get_item(Host, Node, ItemId) of
if MaxItems > 0 ->
PubId = {now(), SubKey},
Item = case get_item(NodeId, ItemId) of
{result, OldItem} ->
OldItem#pubsub_item{modification = PubId,
payload = Payload};
_ ->
#pubsub_item{itemid = {ItemId, {Host, Node}},
creation = {GenKey, now()},
#pubsub_item{itemid = {ItemId, NodeId},
creation = {now(), GenKey},
modification = PubId,
payload = Payload}
end,
Items = [ItemId | GenState#pubsub_state.items--[ItemId]],
{result, {NI, OI}} = remove_extra_items(
Host, Node, MaxItems, Items),
if MaxItems > 0 -> set_item(Item);
true -> ok
end,
set_state(GenState#pubsub_state{items = NI}),
{result, {default, broadcast, OI}}
Items = [ItemId | GenState#pubsub_state.items--[ItemId]],
{result, {NI, OI}} = remove_extra_items(NodeId, MaxItems, Items),
set_item(Item),
set_state(GenState#pubsub_state{items = NI}),
{result, {default, broadcast, OI}};
true ->
{result, {default, broadcast, []}}
end
end.
%% @spec (Host, Node, MaxItems, ItemIds) -> {NewItemIds,OldItemIds}
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% @spec (NodeId, MaxItems, ItemIds) -> {NewItemIds,OldItemIds}
%% NodeId = mod_pubsub:pubsubNodeId()
%% MaxItems = integer() | unlimited
%% ItemIds = [ItemId::string()]
%% NewItemIds = [ItemId::string()]
@ -470,35 +470,34 @@ publish_item(Host, Node, Publisher, PublishModel, MaxItems, ItemId, Payload) ->
%% rules can be used.</p>
%% <p>If another PubSub plugin wants to delegate the item removal (and if the
%% plugin is using the default pubsub storage), it can implements this function like this:
%% ```remove_extra_items(Host, Node, MaxItems, ItemIds) ->
%% node_default:remove_extra_items(Host, Node, MaxItems, ItemIds).'''</p>
remove_extra_items(_Host, _Node, unlimited, ItemIds) ->
%% ```remove_extra_items(NodeId, MaxItems, ItemIds) ->
%% node_default:remove_extra_items(NodeId, MaxItems, ItemIds).'''</p>
remove_extra_items(_NodeId, unlimited, ItemIds) ->
{result, {ItemIds, []}};
remove_extra_items(Host, Node, MaxItems, ItemIds) ->
remove_extra_items(NodeId, MaxItems, ItemIds) ->
NewItems = lists:sublist(ItemIds, MaxItems),
OldItems = lists:nthtail(length(NewItems), ItemIds),
%% Remove extra items:
del_items(Host, Node, OldItems),
del_items(NodeId, OldItems),
%% Return the new items list:
{result, {NewItems, OldItems}}.
%% @spec (Host, Node, JID, ItemId) ->
%% @spec (NodeId, JID, ItemId) ->
%% {error, Reason::stanzaError()} |
%% {result, []}
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% NodeId = mod_pubsub:pubsubNodeId()
%% JID = mod_pubsub:jid()
%% ItemId = string()
%% @doc <p>Triggers item deletion.</p>
%% <p>Default plugin: The user performing the deletion must be the node owner
%% or a publisher.</p>
delete_item(Host, Node, Publisher, ItemId) ->
delete_item(NodeId, Publisher, ItemId) ->
SubKey = jlib:jid_tolower(Publisher),
GenKey = jlib:jid_remove_resource(SubKey),
GenState = get_state(Host, Node, GenKey),
GenState = get_state(NodeId, GenKey),
#pubsub_state{affiliation = Affiliation, items = Items} = GenState,
Allowed = (Affiliation == publisher) orelse (Affiliation == owner)
orelse case get_item(Host, Node, ItemId) of
orelse case get_item(NodeId, ItemId) of
{result, #pubsub_item{creation = {GenKey, _}}} -> true;
_ -> false
end,
@ -507,31 +506,31 @@ delete_item(Host, Node, Publisher, ItemId) ->
%% Requesting entity does not have sufficient privileges
{error, ?ERR_FORBIDDEN};
true ->
case get_item(Host, Node, ItemId) of
{result, _} ->
del_item(Host, Node, ItemId),
case lists:member(ItemId, Items) of
true ->
del_item(NodeId, ItemId),
NewItems = lists:delete(ItemId, Items),
set_state(GenState#pubsub_state{items = NewItems}),
{result, {default, broadcast}};
_ ->
false ->
%% Non-existent node or item
{error, ?ERR_ITEM_NOT_FOUND}
end
end.
%% @spec (Host, Node, Owner) ->
%% @spec (NodeId, Owner) ->
%% {error, Reason::stanzaError()} |
%% {result, {default, broadcast}}
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% NodeId = mod_pubsub:pubsubNodeId()
%% Owner = mod_pubsub:jid()
purge_node(Host, Node, Owner) ->
purge_node(NodeId, Owner) ->
SubKey = jlib:jid_tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey),
GenState = get_state(Host, Node, GenKey),
GenState = get_state(NodeId, GenKey),
case GenState of
#pubsub_state{items = Items, affiliation = owner} ->
del_items(Host, Node, Items),
del_items(NodeId, Items),
set_state(GenState#pubsub_state{items = []}),
{result, {default, broadcast}};
_ ->
%% Entity is not owner
@ -548,45 +547,44 @@ purge_node(Host, Node, Owner) ->
%% the default PubSub module. Otherwise, it should return its own affiliation,
%% that will be added to the affiliation stored in the main
%% <tt>pubsub_state</tt> table.</p>
get_entity_affiliations(Host, Owner) ->
get_entity_affiliations(_Host, Owner) ->
SubKey = jlib:jid_tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey),
States = mnesia:match_object(
#pubsub_state{stateid = {GenKey, {Host, '_'}}, _ = '_'}),
Tr = fun(#pubsub_state{stateid = {_, {_, N}}, affiliation = A}) ->
%% TODO check if Host needed
#pubsub_state{stateid = {GenKey, '_'}, _ = '_'}),
Tr = fun(#pubsub_state{stateid = {_, N}, affiliation = A}) ->
{N, A}
end,
{result, lists:map(Tr, States)}.
get_node_affiliations(Host, Node) ->
{result, States} = get_states(Host, Node),
Tr = fun(#pubsub_state{stateid = {J, {_, _}}, affiliation = A}) ->
get_node_affiliations(NodeId) ->
{result, States} = get_states(NodeId),
Tr = fun(#pubsub_state{stateid = {J, _}, affiliation = A}) ->
{J, A}
end,
{result, lists:map(Tr, States)}.
get_affiliation(Host, Node, Owner) ->
get_affiliation(NodeId, Owner) ->
SubKey = jlib:jid_tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey),
GenState = get_state(Host, Node, GenKey),
GenState = get_state(NodeId, GenKey),
{result, GenState#pubsub_state.affiliation}.
set_affiliation(Host, Node, Owner, Affiliation) ->
set_affiliation(NodeId, Owner, Affiliation) ->
SubKey = jlib:jid_tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey),
GenState = get_state(Host, Node, GenKey),
GenState = get_state(NodeId, GenKey),
case {Affiliation, GenState#pubsub_state.subscription} of
{none, none} ->
del_state(GenState#pubsub_state.stateid);
del_state(NodeId, GenKey);
_ ->
set_state(GenState#pubsub_state{affiliation = Affiliation})
end,
ok.
end.
%% @spec (Host, Owner) -> [{Node,Subscription}]
%% Host = host()
%% Owner = mod_pubsub:jid()
%% Node = mod_pubsub:pubsubNode()
%% @doc <p>Return the current subscriptions for the given user</p>
%% <p>The default module reads subscriptions in the main Mnesia
%% <tt>pubsub_state</tt> table. If a plugin stores its data in the same
@ -594,49 +592,46 @@ set_affiliation(Host, Node, Owner, Affiliation) ->
%% the default PubSub module. Otherwise, it should return its own affiliation,
%% that will be added to the affiliation stored in the main
%% <tt>pubsub_state</tt> table.</p>
get_entity_subscriptions(Host, Owner) ->
get_entity_subscriptions(_Host, Owner) ->
{U, D, _} = SubKey = jlib:jid_tolower(Owner),
GenKey = jlib:jid_remove_resource(SubKey),
States = case SubKey of
GenKey -> mnesia:match_object(
#pubsub_state{stateid = {{U, D, '_'}, {Host, '_'}}, _ = '_'});
#pubsub_state{stateid = {{U, D, '_'}, '_'}, _ = '_'});
_ -> mnesia:match_object(
#pubsub_state{stateid = {GenKey, {Host, '_'}}, _ = '_'})
#pubsub_state{stateid = {GenKey, '_'}, _ = '_'})
++ mnesia:match_object(
#pubsub_state{stateid = {SubKey, {Host, '_'}}, _ = '_'})
#pubsub_state{stateid = {SubKey, '_'}, _ = '_'})
end,
Tr = fun(#pubsub_state{stateid = {J, {_, N}}, subscription = S}) ->
Tr = fun(#pubsub_state{stateid = {J, N}, subscription = S}) ->
{N, S, J}
end,
{result, lists:map(Tr, States)}.
get_node_subscriptions(Host, Node) ->
{result, States} = get_states(Host, Node),
Tr = fun(#pubsub_state{stateid = {J, {_, _}}, subscription = S}) ->
get_node_subscriptions(NodeId) ->
{result, States} = get_states(NodeId),
Tr = fun(#pubsub_state{stateid = {J, _}, subscription = S}) ->
{J, S}
end,
{result, lists:map(Tr, States)}.
get_subscription(Host, Node, Owner) ->
get_subscription(NodeId, Owner) ->
SubKey = jlib:jid_tolower(Owner),
SubState = get_state(Host, Node, SubKey),
SubState = get_state(NodeId, SubKey),
{result, SubState#pubsub_state.subscription}.
set_subscription(Host, Node, Owner, Subscription) ->
set_subscription(NodeId, Owner, Subscription) ->
SubKey = jlib:jid_tolower(Owner),
SubState = get_state(Host, Node, SubKey),
SubState = get_state(NodeId, SubKey),
case {Subscription, SubState#pubsub_state.affiliation} of
{none, none} ->
del_state(SubState#pubsub_state.stateid);
del_state(NodeId, SubKey);
_ ->
set_state(SubState#pubsub_state{subscription = Subscription})
end,
ok.
end.
%% @spec (Host, Node) -> [States] | []
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% Item = mod_pubsub:pubsubItems()
%% @spec (NodeId) -> [States] | []
%% NodeId = mod_pubsub:pubsubNodeId()
%% @doc Returns the list of stored states for a given node.
%% <p>For the default PubSub module, states are stored in Mnesia database.</p>
%% <p>We can consider that the pubsub_state table have been created by the main
@ -645,21 +640,20 @@ set_subscription(Host, Node, Owner, Subscription) ->
%% relational database).</p>
%% <p>If a PubSub plugin wants to delegate the states storage to the default node,
%% they can implement this function like this:
%% ```get_states(Host, Node) ->
%% node_default:get_states(Host, Node).'''</p>
get_states(Host, Node) ->
%% ```get_states(NodeId) ->
%% node_default:get_states(NodeId).'''</p>
get_states(NodeId) ->
States = mnesia:match_object(
#pubsub_state{stateid = {'_', {Host, Node}}, _ = '_'}),
#pubsub_state{stateid = {'_', NodeId}, _ = '_'}),
{result, States}.
%% @spec (JID, Host, Node) -> [State] | []
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% @spec (NodeId, JID) -> [State] | []
%% NodeId = mod_pubsub:pubsubNodeId()
%% JID = mod_pubsub:jid()
%% State = mod_pubsub:pubsubItems()
%% @doc <p>Returns a state (one state list), given its reference.</p>
get_state(Host, Node, JID) ->
StateId = {JID, {Host, Node}},
get_state(NodeId, JID) ->
StateId = {JID, NodeId},
case mnesia:read({pubsub_state, StateId}) of
[State] when is_record(State, pubsub_state) -> State;
_ -> #pubsub_state{stateid=StateId}
@ -676,12 +670,11 @@ set_state(_) ->
%% @spec (StateId) -> ok | {error, Reason::stanzaError()}
%% StateId = mod_pubsub:pubsubStateId()
%% @doc <p>Delete a state from database.</p>
del_state(StateId) ->
mnesia:delete({pubsub_state, StateId}).
del_state(NodeId, JID) ->
mnesia:delete({pubsub_state, {JID, NodeId}}).
%% @spec (Host, Node, From) -> [Items] | []
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% @spec (NodeId, From) -> [Items] | []
%% NodeId = mod_pubsub:pubsubNodeId()
%% Items = mod_pubsub:pubsubItems()
%% @doc Returns the list of stored items for a given node.
%% <p>For the default PubSub module, items are stored in Mnesia database.</p>
@ -691,16 +684,16 @@ del_state(StateId) ->
%% relational database), or they can even decide not to persist any items.</p>
%% <p>If a PubSub plugin wants to delegate the item storage to the default node,
%% they can implement this function like this:
%% ```get_items(Host, Node, From) ->
%% node_default:get_items(Host, Node, From).'''</p>
get_items(Host, Node, _From) ->
%% ```get_items(NodeId, From) ->
%% node_default:get_items(NodeId, From).'''</p>
get_items(NodeId, _From) ->
Items = mnesia:match_object(
#pubsub_item{itemid = {'_', {Host, Node}}, _ = '_'}),
#pubsub_item{itemid = {'_', NodeId}, _ = '_'}),
{result, Items}.
get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId) ->
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId) ->
SubKey = jlib:jid_tolower(JID),
GenKey = jlib:jid_remove_resource(SubKey),
GenState = get_state(Host, Node, GenKey),
GenState = get_state(NodeId, GenKey),
Affiliation = GenState#pubsub_state.affiliation,
Subscription = GenState#pubsub_state.subscription,
Whitelisted = can_fetch_item(Affiliation, Subscription),
@ -730,26 +723,25 @@ get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, _SubI
%% % Payment is required for a subscription
%% {error, ?ERR_PAYMENT_REQUIRED};
true ->
get_items(Host, Node, JID)
get_items(NodeId, JID)
end.
%% @spec (Host, Node, ItemId) -> [Item] | []
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% @spec (NodeId, ItemId) -> [Item] | []
%% NodeId = mod_pubsub:pubsubNodeId()
%% ItemId = string()
%% Item = mod_pubsub:pubsubItems()
%% @doc <p>Returns an item (one item list), given its reference.</p>
get_item(Host, Node, ItemId) ->
case mnesia:read({pubsub_item, {ItemId, {Host, Node}}}) of
get_item(NodeId, ItemId) ->
case mnesia:read({pubsub_item, {ItemId, NodeId}}) of
[Item] when is_record(Item, pubsub_item) ->
{result, Item};
_ ->
{error, ?ERR_ITEM_NOT_FOUND}
end.
get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId) ->
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId) ->
SubKey = jlib:jid_tolower(JID),
GenKey = jlib:jid_remove_resource(SubKey),
GenState = get_state(Host, Node, GenKey),
GenState = get_state(NodeId, GenKey),
Affiliation = GenState#pubsub_state.affiliation,
Subscription = GenState#pubsub_state.subscription,
Whitelisted = can_fetch_item(Affiliation, Subscription),
@ -779,7 +771,7 @@ get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup
%% % Payment is required for a subscription
%% {error, ?ERR_PAYMENT_REQUIRED};
true ->
get_item(Host, Node, ItemId)
get_item(NodeId, ItemId)
end.
%% @spec (Item) -> ok | {error, Reason::stanzaError()}
@ -790,16 +782,15 @@ set_item(Item) when is_record(Item, pubsub_item) ->
set_item(_) ->
{error, ?ERR_INTERNAL_SERVER_ERROR}.
%% @spec (Host, Node, ItemId) -> ok | {error, Reason::stanzaError()}
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% @spec (NodeId, ItemId) -> ok | {error, Reason::stanzaError()}
%% NodeId = mod_pubsub:pubsubNodeId()
%% ItemId = string()
%% @doc <p>Delete an item from database.</p>
del_item(Host, Node, ItemId) ->
mnesia:delete({pubsub_item, {ItemId, {Host, Node}}}).
del_items(Host, Node, ItemIds) ->
del_item(NodeId, ItemId) ->
mnesia:delete({pubsub_item, {ItemId, NodeId}}).
del_items(NodeId, ItemIds) ->
lists:foreach(fun(ItemId) ->
del_item(Host, Node, ItemId)
del_item(NodeId, ItemId)
end, ItemIds).
%% @doc <p>Return the name of the node if known: Default is to return

View File

@ -41,29 +41,29 @@
-export([init/3, terminate/2,
options/0, features/0,
create_node_permission/6,
create_node/3,
delete_node/2,
purge_node/3,
subscribe_node/8,
unsubscribe_node/5,
publish_item/7,
delete_item/4,
remove_extra_items/4,
create_node/2,
delete_node/1,
purge_node/2,
subscribe_node/7,
unsubscribe_node/4,
publish_item/6,
delete_item/3,
remove_extra_items/3,
get_entity_affiliations/2,
get_node_affiliations/2,
get_affiliation/3,
set_affiliation/4,
get_node_affiliations/1,
get_affiliation/2,
set_affiliation/3,
get_entity_subscriptions/2,
get_node_subscriptions/2,
get_subscription/3,
set_subscription/4,
get_states/2,
get_state/3,
get_node_subscriptions/1,
get_subscription/2,
set_subscription/3,
get_states/1,
get_state/2,
set_state/1,
get_items/7,
get_items/3,
get_item/8,
get_item/3,
get_items/6,
get_items/2,
get_item/7,
get_item/2,
set_item/1,
get_item_name/3
]).
@ -111,79 +111,81 @@ features() ->
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_default:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
create_node(Host, Node, Owner) ->
node_default:create_node(Host, Node, Owner).
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
delete_node(Host, Removed) ->
node_default:delete_node(Host, Removed).
delete_node(Removed) ->
node_default:delete_node(Removed).
subscribe_node(_Host, _Node, _Sender, _Subscriber, _AccessModel,
subscribe_node(_NodeId, _Sender, _Subscriber, _AccessModel,
_SendLast, _PresenceSubscription, _RosterGroup) ->
{error, ?ERR_FORBIDDEN}.
unsubscribe_node(_Host, _Node, _Sender, _Subscriber, _SubID) ->
unsubscribe_node(_NodeId, _Sender, _Subscriber, _SubID) ->
{error, ?ERR_FORBIDDEN}.
publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload) ->
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
lists:foreach(fun(SubNode) ->
node_default:publish_item(
Host, SubNode, Publisher, Model,
SubNode#pubsub_node.id, Publisher, Model,
MaxItems, ItemId, Payload)
end, nodetree_default:get_subnodes(Host, Node, Publisher)).
end, nodetree_default:get_subnodes(NodeId, Publisher)).
remove_extra_items(_Host, _Node, _MaxItems, ItemIds) ->
remove_extra_items(_NodeId, _MaxItems, ItemIds) ->
{result, {ItemIds, []}}.
delete_item(_Host, _Node, _JID, _ItemId) ->
delete_item(_NodeId, _JID, _ItemId) ->
{error, ?ERR_ITEM_NOT_FOUND}.
purge_node(_Host, _Node, _Owner) ->
purge_node(_NodeId, _Owner) ->
{error, ?ERR_FORBIDDEN}.
get_entity_affiliations(_Host, _Owner) ->
{result, []}.
get_node_affiliations(_Host, _Node) ->
get_node_affiliations(_NodeId) ->
{result, []}.
get_affiliation(_Host, _Node, _Owner) ->
get_affiliation(_NodeId, _Owner) ->
{result, []}.
set_affiliation(Host, Node, Owner, Affiliation) ->
node_default:set_affiliation(Host, Node, Owner, Affiliation).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(_Host, _Owner) ->
{result, []}.
get_node_subscriptions(_Host, _Node) ->
get_node_subscriptions(NodeId) ->
%% note: get_node_subscriptions is used for broadcasting
%% DO NOT REMOVE
node_default:get_node_subscriptions(NodeId).
get_subscription(_NodeId, _Owner) ->
{result, []}.
get_subscription(_Host, _Node, _Owner) ->
{result, []}.
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
set_subscription(Host, Node, Owner, Subscription) ->
node_default:set_subscription(Host, Node, Owner, Subscription).
get_states(NodeId) ->
node_default:get_states(NodeId).
get_states(Host, Node) ->
node_default:get_states(Host, Node).
get_state(Host, Node, JID) ->
node_default:get_state(Host, Node, JID).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
get_items(Host, Node, From) ->
node_default:get_items(Host, Node, From).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(Host, Node, ItemId) ->
node_default:get_item(Host, Node, ItemId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).

View File

@ -34,29 +34,29 @@
-export([init/3, terminate/2,
options/0, features/0,
create_node_permission/6,
create_node/3,
delete_node/2,
purge_node/3,
subscribe_node/8,
unsubscribe_node/5,
publish_item/7,
delete_item/4,
remove_extra_items/4,
create_node/2,
delete_node/1,
purge_node/2,
subscribe_node/7,
unsubscribe_node/4,
publish_item/6,
delete_item/3,
remove_extra_items/3,
get_entity_affiliations/2,
get_node_affiliations/2,
get_affiliation/3,
set_affiliation/4,
get_node_affiliations/1,
get_affiliation/2,
set_affiliation/3,
get_entity_subscriptions/2,
get_node_subscriptions/2,
get_subscription/3,
set_subscription/4,
get_states/2,
get_state/3,
get_node_subscriptions/1,
get_subscription/2,
set_subscription/3,
get_states/1,
get_state/2,
set_state/1,
get_items/7,
get_items/3,
get_item/8,
get_item/3,
get_items/6,
get_items/2,
get_item/7,
get_item/2,
set_item/1,
get_item_name/3
]).
@ -101,74 +101,74 @@ create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
end,
{result, Allowed}.
create_node(Host, Node, Owner) ->
node_default:create_node(Host, Node, Owner).
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
delete_node(Host, Removed) ->
node_default:delete_node(Host, Removed).
delete_node(Removed) ->
node_default:delete_node(Removed).
subscribe_node(Host, Node, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(Host, Node, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
unsubscribe_node(Host, Node, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(Host, Node, Sender, Subscriber, SubID).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(Host, Node, MaxItems, ItemIds) ->
node_default:remove_extra_items(Host, Node, MaxItems, ItemIds).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(Host, Node, JID, ItemId) ->
node_default:delete_item(Host, Node, JID, ItemId).
delete_item(NodeId, JID, ItemId) ->
node_default:delete_item(NodeId, JID, ItemId).
purge_node(Host, Node, Owner) ->
node_default:purge_node(Host, Node, Owner).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
get_entity_affiliations(Host, Owner) ->
node_default:get_entity_affiliations(Host, Owner).
get_node_affiliations(Host, Node) ->
node_default:get_node_affiliations(Host, Node).
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
get_affiliation(Host, Node, Owner) ->
node_default:get_affiliation(Host, Node, Owner).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
set_affiliation(Host, Node, Owner, Affiliation) ->
node_default:set_affiliation(Host, Node, Owner, Affiliation).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) ->
node_default:get_entity_subscriptions(Host, Owner).
get_node_subscriptions(Host, Node) ->
node_default:get_node_subscriptions(Host, Node).
get_node_subscriptions(NodeId) ->
node_default:get_node_subscriptions(NodeId).
get_subscription(Host, Node, Owner) ->
node_default:get_subscription(Host, Node, Owner).
get_subscription(NodeId, Owner) ->
node_default:get_subscription(NodeId, Owner).
set_subscription(Host, Node, Owner, Subscription) ->
node_default:set_subscription(Host, Node, Owner, Subscription).
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
get_states(Host, Node) ->
node_default:get_states(Host, Node).
get_states(NodeId) ->
node_default:get_states(NodeId).
get_state(Host, Node, JID) ->
node_default:get_state(Host, Node, JID).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
get_items(Host, Node, From) ->
node_default:get_items(Host, Node, From).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(Host, Node, ItemId) ->
node_default:get_item(Host, Node, ItemId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).

View File

@ -46,29 +46,29 @@
-export([init/3, terminate/2,
options/0, features/0,
create_node_permission/6,
create_node/3,
delete_node/2,
purge_node/3,
subscribe_node/8,
unsubscribe_node/5,
publish_item/7,
delete_item/4,
remove_extra_items/4,
create_node/2,
delete_node/1,
purge_node/2,
subscribe_node/7,
unsubscribe_node/4,
publish_item/6,
delete_item/3,
remove_extra_items/3,
get_entity_affiliations/2,
get_node_affiliations/2,
get_affiliation/3,
set_affiliation/4,
get_node_affiliations/1,
get_affiliation/2,
set_affiliation/3,
get_entity_subscriptions/2,
get_node_subscriptions/2,
get_subscription/3,
set_subscription/4,
get_states/2,
get_state/3,
get_node_subscriptions/1,
get_subscription/2,
set_subscription/3,
get_states/1,
get_state/2,
set_state/1,
get_items/7,
get_items/3,
get_item/8,
get_item/3,
get_items/6,
get_items/2,
get_item/7,
get_item/2,
set_item/1,
get_item_name/3
]).
@ -119,77 +119,77 @@ features() ->
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_pep:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
create_node(Host, Node, Owner) ->
node_pep:create_node(Host, Node, Owner).
create_node(NodeId, Owner) ->
node_pep:create_node(NodeId, Owner).
delete_node(Host, Removed) ->
node_pep:delete_node(Host, Removed).
delete_node(Removed) ->
node_pep:delete_node(Removed).
subscribe_node(Host, Node, Sender, Subscriber, AccessModel,
subscribe_node(NodeId, Sender, Subscriber, AccessModel,
SendLast, PresenceSubscription, RosterGroup) ->
node_pep:subscribe_node(
Host, Node, Sender, Subscriber, AccessModel, SendLast,
NodeId, Sender, Subscriber, AccessModel, SendLast,
PresenceSubscription, RosterGroup).
unsubscribe_node(Host, Node, Sender, Subscriber, SubID) ->
node_pep:unsubscribe_node(Host, Node, Sender, Subscriber, SubID).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
node_pep:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload) ->
node_pep:publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_pep:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(Host, Node, MaxItems, ItemIds) ->
node_pep:remove_extra_items(Host, Node, MaxItems, ItemIds).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_pep:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(Host, Node, JID, ItemId) ->
node_pep:delete_item(Host, Node, JID, ItemId).
delete_item(NodeId, JID, ItemId) ->
node_pep:delete_item(NodeId, JID, ItemId).
purge_node(Host, Node, Owner) ->
node_pep:purge_node(Host, Node, Owner).
purge_node(NodeId, Owner) ->
node_pep:purge_node(NodeId, Owner).
get_entity_affiliations(Host, Owner) ->
node_pep:get_entity_affiliations(Host, Owner).
get_node_affiliations(Host, Node) ->
node_pep:get_node_affiliations(Host, Node).
get_node_affiliations(NodeId) ->
node_pep:get_node_affiliations(NodeId).
get_affiliation(Host, Node, Owner) ->
node_pep:get_affiliation(Host, Node, Owner).
get_affiliation(NodeId, Owner) ->
node_pep:get_affiliation(NodeId, Owner).
set_affiliation(Host, Node, Owner, Affiliation) ->
node_pep:set_affiliation(Host, Node, Owner, Affiliation).
set_affiliation(NodeId, Owner, Affiliation) ->
node_pep:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host,Owner) ->
get_entity_subscriptions(Host, Owner) ->
node_pep:get_entity_subscriptions(Host, Owner).
get_node_subscriptions(Host, Node) ->
node_pep:get_node_subscriptions(Host, Node).
get_node_subscriptions(NodeId) ->
node_pep:get_node_subscriptions(NodeId).
get_subscription(Host,Node,Owner) ->
node_pep:get_subscription(Host,Node,Owner).
get_subscription(NodeId, Owner) ->
node_pep:get_subscription(NodeId, Owner).
set_subscription(Host, Node, Owner, Subscription) ->
node_pep:set_subscription(Host, Node, Owner, Subscription).
set_subscription(NodeId, Owner, Subscription) ->
node_pep:set_subscription(NodeId, Owner, Subscription).
get_states(Host, Node) ->
node_pep:get_states(Host, Node).
get_states(NodeId) ->
node_pep:get_states(NodeId).
get_state(Host, Node, JID) ->
node_pep:get_state(Host, Node, JID).
get_state(NodeId, JID) ->
node_pep:get_state(NodeId, JID).
set_state(State) ->
node_pep:set_state(State).
get_items(Host, Node, From) ->
node_pep:get_items(Host, Node, From).
get_items(NodeId, From) ->
node_pep:get_items(NodeId, From).
get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_pep:get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_pep:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(Host, Node, ItemId) ->
node_pep:get_item(Host, Node, ItemId).
get_item(NodeId, ItemId) ->
node_pep:get_item(NodeId, ItemId).
get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_pep:get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_pep:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_pep:set_item(Item).

View File

@ -39,29 +39,29 @@
-export([init/3, terminate/2,
options/0, features/0,
create_node_permission/6,
create_node/3,
delete_node/2,
purge_node/3,
subscribe_node/8,
unsubscribe_node/5,
publish_item/7,
delete_item/4,
remove_extra_items/4,
create_node/2,
delete_node/1,
purge_node/2,
subscribe_node/7,
unsubscribe_node/4,
publish_item/6,
delete_item/3,
remove_extra_items/3,
get_entity_affiliations/2,
get_node_affiliations/2,
get_affiliation/3,
set_affiliation/4,
get_node_affiliations/1,
get_affiliation/2,
set_affiliation/3,
get_entity_subscriptions/2,
get_node_subscriptions/2,
get_subscription/3,
set_subscription/4,
get_states/2,
get_state/3,
get_node_subscriptions/1,
get_subscription/2,
set_subscription/3,
get_states/1,
get_state/2,
set_state/1,
get_items/7,
get_items/3,
get_item/8,
get_item/3,
get_items/6,
get_items/2,
get_item/7,
get_item/2,
set_item/1,
get_item_name/3
]).
@ -131,92 +131,92 @@ create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
end,
{result, Allowed}.
create_node(Host, Node, Owner) ->
case node_default:create_node(Host, Node, Owner) of
create_node(NodeId, Owner) ->
case node_default:create_node(NodeId, Owner) of
{result, _} -> {result, []};
Error -> Error
end.
delete_node(Host, Removed) ->
case node_default:delete_node(Host, Removed) of
delete_node(Removed) ->
case node_default:delete_node(Removed) of
{result, {_, _, Removed}} -> {result, {[], Removed}};
Error -> Error
end.
subscribe_node(Host, Node, Sender, Subscriber, AccessModel,
subscribe_node(NodeId, Sender, Subscriber, AccessModel,
SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(
Host, Node, Sender, Subscriber, AccessModel, SendLast,
NodeId, Sender, Subscriber, AccessModel, SendLast,
PresenceSubscription, RosterGroup).
unsubscribe_node(Host, Node, Sender, Subscriber, SubID) ->
case node_default:unsubscribe_node(Host, Node, Sender, Subscriber, SubID) of
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
case node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID) of
{error, Error} -> {error, Error};
{result, _} -> {result, []}
end.
publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(Host, Node, MaxItems, ItemIds) ->
node_default:remove_extra_items(Host, Node, MaxItems, ItemIds).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(Host, Node, JID, ItemId) ->
node_default:delete_item(Host, Node, JID, ItemId).
delete_item(NodeId, JID, ItemId) ->
node_default:delete_item(NodeId, JID, ItemId).
purge_node(Host, Node, Owner) ->
node_default:purge_node(Host, Node, Owner).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
get_entity_affiliations(_Host, Owner) ->
OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
node_default:get_entity_affiliations(OwnerKey, Owner).
get_node_affiliations(Host, Node) ->
OwnerKey = jlib:jid_remove_resource(Host),
node_default:get_node_affiliations(OwnerKey, Node).
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
get_affiliation(_Host, Node, Owner) ->
OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
node_default:get_affiliation(OwnerKey, Node, Owner).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
set_affiliation(_Host, Node, Owner, Affiliation) ->
OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
State = get_state(OwnerKey, Node, OwnerKey),
set_state(State#pubsub_state{affiliation = Affiliation}),
ok.
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(_Host, _Owner) ->
{result, []}.
get_node_subscriptions(_Host, _Node) ->
{result, []}.
get_node_subscriptions(NodeId) ->
%% note: get_node_subscriptions is used for broadcasting
%% there should not have any subscriptions
%% 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).
get_subscription(_Host, _Node, _Owner) ->
get_subscription(_NodeId, _Owner) ->
{result, none}.
set_subscription(_Host, _Node, _Owner, _Subscription) ->
set_subscription(_NodeId, _Owner, _Subscription) ->
ok.
get_states(Host, Node) ->
node_default:get_states(Host, Node).
get_states(NodeId) ->
node_default:get_states(NodeId).
get_state(Host, Node, JID) ->
node_default:get_state(Host, Node, JID).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
get_items(Host, Node, From) ->
node_default:get_items(Host, Node, From).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(Host, Node, ItemId) ->
node_default:get_item(Host, Node, ItemId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).

View File

@ -43,29 +43,29 @@
-export([init/3, terminate/2,
options/0, features/0,
create_node_permission/6,
create_node/3,
delete_node/2,
purge_node/3,
subscribe_node/8,
unsubscribe_node/5,
publish_item/7,
delete_item/4,
remove_extra_items/4,
create_node/2,
delete_node/1,
purge_node/2,
subscribe_node/7,
unsubscribe_node/4,
publish_item/6,
delete_item/3,
remove_extra_items/3,
get_entity_affiliations/2,
get_node_affiliations/2,
get_affiliation/3,
set_affiliation/4,
get_node_affiliations/1,
get_affiliation/2,
set_affiliation/3,
get_entity_subscriptions/2,
get_node_subscriptions/2,
get_subscription/3,
set_subscription/4,
get_states/2,
get_state/3,
get_node_subscriptions/1,
get_subscription/2,
set_subscription/3,
get_states/1,
get_state/2,
set_state/1,
get_items/7,
get_items/3,
get_item/8,
get_item/3,
get_items/6,
get_items/2,
get_item/7,
get_item/2,
set_item/1,
get_item_name/3
]).
@ -115,76 +115,76 @@ create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_default:create_node_permission(Host, ServerHost, Node, ParentNode,
Owner, Access).
create_node(Host, Node, Owner) ->
node_default:create_node(Host, Node, Owner).
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
delete_node(Host, Removed) ->
node_default:delete_node(Host, Removed).
delete_node(Removed) ->
node_default:delete_node(Removed).
subscribe_node(Host, Node, Sender, Subscriber, AccessModel, SendLast,
subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast,
PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(Host, Node, Sender, Subscriber, AccessModel,
node_default:subscribe_node(NodeId, Sender, Subscriber, AccessModel,
SendLast, PresenceSubscription, RosterGroup).
unsubscribe_node(Host, Node, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(Host, Node, Sender, Subscriber, SubID).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(Host, Node, MaxItems, ItemIds) ->
node_default:remove_extra_items(Host, Node, MaxItems, ItemIds).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(Host, Node, JID, ItemId) ->
node_default:delete_item(Host, Node, JID, ItemId).
delete_item(NodeId, JID, ItemId) ->
node_default:delete_item(NodeId, JID, ItemId).
purge_node(Host, Node, Owner) ->
node_default:purge_node(Host, Node, Owner).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
get_entity_affiliations(Host, Owner) ->
node_default:get_entity_affiliations(Host, Owner).
get_node_affiliations(Host, Node) ->
node_default:get_node_affiliations(Host, Node).
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
get_affiliation(Host, Node, Owner) ->
node_default:get_affiliation(Host, Node, Owner).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
set_affiliation(Host, Node, Owner, Affiliation) ->
node_default:set_affiliation(Host, Node, Owner, Affiliation).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) ->
node_default:get_entity_subscriptions(Host, Owner).
get_node_subscriptions(Host, Node) ->
node_default:get_node_subscriptions(Host, Node).
get_node_subscriptions(NodeId) ->
node_default:get_node_subscriptions(NodeId).
get_subscription(Host, Node, Owner) ->
node_default:get_subscription(Host, Node, Owner).
get_subscription(NodeId, Owner) ->
node_default:get_subscription(NodeId, Owner).
set_subscription(Host, Node, Owner, Subscription) ->
node_default:set_subscription(Host, Node, Owner, Subscription).
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
get_states(Host, Node) ->
node_default:get_states(Host, Node).
get_states(NodeId) ->
node_default:get_states(NodeId).
get_state(Host, Node, JID) ->
node_default:get_state(Host, Node, JID).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
get_items(Host, Node, From) ->
node_default:get_items(Host, Node, From).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(Host, Node, ItemId) ->
node_default:get_item(Host, Node, ItemId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).

View File

@ -43,29 +43,29 @@
-export([init/3, terminate/2,
options/0, features/0,
create_node_permission/6,
create_node/3,
delete_node/2,
purge_node/3,
subscribe_node/8,
unsubscribe_node/5,
publish_item/7,
delete_item/4,
remove_extra_items/4,
create_node/2,
delete_node/1,
purge_node/2,
subscribe_node/7,
unsubscribe_node/4,
publish_item/6,
delete_item/3,
remove_extra_items/3,
get_entity_affiliations/2,
get_node_affiliations/2,
get_affiliation/3,
set_affiliation/4,
get_node_affiliations/1,
get_affiliation/2,
set_affiliation/3,
get_entity_subscriptions/2,
get_node_subscriptions/2,
get_subscription/3,
set_subscription/4,
get_states/2,
get_state/3,
get_node_subscriptions/1,
get_subscription/2,
set_subscription/3,
get_states/1,
get_state/2,
set_state/1,
get_items/7,
get_items/3,
get_item/8,
get_item/3,
get_items/6,
get_items/2,
get_item/7,
get_item/2,
set_item/1,
get_item_name/3
]).
@ -114,74 +114,74 @@ features() ->
create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access) ->
node_default:create_node_permission(Host, ServerHost, Node, ParentNode, Owner, Access).
create_node(Host, Node, Owner) ->
node_default:create_node(Host, Node, Owner).
create_node(NodeId, Owner) ->
node_default:create_node(NodeId, Owner).
delete_node(Host, Removed) ->
node_default:delete_node(Host, Removed).
delete_node(Removed) ->
node_default:delete_node(Removed).
subscribe_node(Host, Node, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(Host, Node, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup) ->
node_default:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup).
unsubscribe_node(Host, Node, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(Host, Node, Sender, Subscriber, SubID).
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
node_default:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(Host, Node, Publisher, Model, MaxItems, ItemId, Payload).
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
node_default:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
remove_extra_items(Host, Node, MaxItems, ItemIds) ->
node_default:remove_extra_items(Host, Node, MaxItems, ItemIds).
remove_extra_items(NodeId, MaxItems, ItemIds) ->
node_default:remove_extra_items(NodeId, MaxItems, ItemIds).
delete_item(Host, Node, JID, ItemId) ->
node_default:delete_item(Host, Node, JID, ItemId).
delete_item(NodeId, JID, ItemId) ->
node_default:delete_item(NodeId, JID, ItemId).
purge_node(Host, Node, Owner) ->
node_default:purge_node(Host, Node, Owner).
purge_node(NodeId, Owner) ->
node_default:purge_node(NodeId, Owner).
get_entity_affiliations(Host, Owner) ->
node_default:get_entity_affiliations(Host, Owner).
get_node_affiliations(Host, Node) ->
node_default:get_node_affiliations(Host, Node).
get_node_affiliations(NodeId) ->
node_default:get_node_affiliations(NodeId).
get_affiliation(Host, Node, Owner) ->
node_default:get_affiliation(Host, Node, Owner).
get_affiliation(NodeId, Owner) ->
node_default:get_affiliation(NodeId, Owner).
set_affiliation(Host, Node, Owner, Affiliation) ->
node_default:set_affiliation(Host, Node, Owner, Affiliation).
set_affiliation(NodeId, Owner, Affiliation) ->
node_default:set_affiliation(NodeId, Owner, Affiliation).
get_entity_subscriptions(Host, Owner) ->
node_default:get_entity_subscriptions(Host, Owner).
get_node_subscriptions(Host, Node) ->
node_default:get_node_subscriptions(Host, Node).
get_node_subscriptions(NodeId) ->
node_default:get_node_subscriptions(NodeId).
get_subscription(Host, Node, Owner) ->
node_default:get_subscription(Host, Node, Owner).
get_subscription(NodeId, Owner) ->
node_default:get_subscription(NodeId, Owner).
set_subscription(Host, Node, Owner, Subscription) ->
node_default:set_subscription(Host, Node, Owner, Subscription).
set_subscription(NodeId, Owner, Subscription) ->
node_default:set_subscription(NodeId, Owner, Subscription).
get_states(Host, Node) ->
node_default:get_states(Host, Node).
get_states(NodeId) ->
node_default:get_states(NodeId).
get_state(Host, Node, JID) ->
node_default:get_state(Host, Node, JID).
get_state(NodeId, JID) ->
node_default:get_state(NodeId, JID).
set_state(State) ->
node_default:set_state(State).
get_items(Host, Node, From) ->
node_default:get_items(Host, Node, From).
get_items(NodeId, From) ->
node_default:get_items(NodeId, From).
get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(Host, Node, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(Host, Node, ItemId) ->
node_default:get_item(Host, Node, ItemId).
get_item(NodeId, ItemId) ->
node_default:get_item(NodeId, ItemId).
get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(Host, Node, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
node_default:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
set_item(Item) ->
node_default:set_item(Item).

View File

@ -50,7 +50,7 @@
get_nodes/2,
get_nodes/1,
get_subnodes/3,
get_subnodes_tree/2,
get_subnodes_tree/3,
create_node/5,
delete_node/2
]).
@ -75,9 +75,10 @@ init(_Host, _ServerHost, _Opts) ->
{attributes, record_info(fields, pubsub_node)}]),
NodesFields = record_info(fields, pubsub_node),
case mnesia:table_info(pubsub_node, attributes) of
[host_node, host_parent, info] -> ok; % old schema, updated later by pubsub
NodesFields -> ok;
_ -> mnesia:transform_table(pubsub_node, ignore, NodesFields)
_ ->
ok
%% mnesia:transform_table(pubsub_state, ignore, StatesFields)
end,
ok.
terminate(_Host, _ServerHost) ->
@ -96,12 +97,11 @@ set_node(Record) when is_record(Record, pubsub_node) ->
set_node(_) ->
{error, ?ERR_INTERNAL_SERVER_ERROR}.
get_node(Host, Node, _From) ->
get_node(Host, Node).
%% @spec (Host, Node) -> pubsubNode() | {error, Reason}
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
get_node(Host, Node, _From) ->
get_node(Host, Node).
get_node(Host, Node) ->
case catch mnesia:read({pubsub_node, {Host, Node}}) of
[Record] when is_record(Record, pubsub_node) -> Record;
@ -109,44 +109,48 @@ get_node(Host, Node) ->
Error -> Error
end.
get_nodes(Key, _From) ->
get_nodes(Key).
%% @spec (Key) -> [pubsubNode()] | {error, Reason}
%% Key = mod_pubsub:host() | mod_pubsub:jid()
get_nodes(Key) ->
mnesia:match_object(#pubsub_node{nodeid = {Key, '_'}, _ = '_'}).
%% @spec (Host) -> [pubsubNode()] | {error, Reason}
%% Host = mod_pubsub:host() | mod_pubsub:jid()
get_nodes(Host, _From) ->
get_nodes(Host).
get_nodes(Host) ->
mnesia:match_object(#pubsub_node{nodeid = {Host, '_'}, _ = '_'}).
%% @spec (Host, Node, From) -> [pubsubNode()] | {error, Reason}
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% From = mod_pubsub:jid()
get_subnodes(Host, Node, _From) ->
mnesia:match_object(#pubsub_node{parentid = {Host, Node}, _ = '_'}).
get_subnodes(Host, Node).
get_subnodes(Host, Node) ->
mnesia:match_object(#pubsub_node{nodeid = {Host, '_'}, parent = Node, _ = '_'}).
%% @spec (Host, Index) -> [pubsubNode()] | {error, Reason}
%% @spec (Host, Index) -> [pubsubNodeIdx()] | {error, Reason}
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% From = mod_pubsub:jid()
get_subnodes_tree(Host, Node, _From) ->
get_subnodes_tree(Host, Node).
get_subnodes_tree(Host, Node) ->
mnesia:foldl(fun(#pubsub_node{nodeid = {H, N}}, Acc) ->
mnesia:foldl(fun(#pubsub_node{nodeid = {H, N}} = R, Acc) ->
case lists:prefix(Node, N) and (H == Host) of
true -> [N | Acc];
true -> [R | Acc];
_ -> Acc
end
end, [], pubsub_node).
%% @spec (Key, Node, Type, Owner, Options) -> ok | {error, Reason}
%% Key = mod_pubsub:host() | mod_pubsub:jid()
%% @spec (Host, Node, Type, Owner, Options) -> ok | {error, Reason}
%% Host = mod_pubsub:host() | mod_pubsub:jid()
%% Node = mod_pubsub:pubsubNode()
%% NodeType = mod_pubsub:nodeType()
%% Owner = mod_pubsub:jid()
%% Options = list()
create_node(Key, Node, Type, Owner, Options) ->
OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
case mnesia:read({pubsub_node, {Key, Node}}) of
create_node(Host, Node, Type, Owner, Options) ->
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
case mnesia:read({pubsub_node, {Host, Node}}) of
[] ->
{ParentNode, ParentExists} =
case Key of
case Host of
{_U, _S, _R} ->
%% This is special case for PEP handling
%% PEP does not uses hierarchy
@ -157,7 +161,7 @@ create_node(Key, Node, Type, Owner, Options) ->
[] ->
{[], true};
_ ->
case mnesia:read({pubsub_node, {Key, Parent}}) of
case mnesia:read({pubsub_node, {Host, Parent}}) of
[] -> {Parent, false};
_ -> {Parent, true}
end
@ -165,13 +169,14 @@ create_node(Key, Node, Type, Owner, Options) ->
end,
case ParentExists of
true ->
%% Service requires registration
%%{error, ?ERR_REGISTRATION_REQUIRED};
mnesia:write(#pubsub_node{nodeid = {Key, Node},
parentid = {Key, ParentNode},
NodeId = pubsub_index:new(node),
mnesia:write(#pubsub_node{nodeid = {Host, Node},
id = NodeId,
parent = ParentNode,
type = Type,
owners = [OwnerKey],
options = Options});
owners = [BJID],
options = Options}),
{ok, NodeId};
false ->
%% Requesting entity is prohibited from creating nodes
{error, ?ERR_FORBIDDEN}
@ -181,12 +186,13 @@ create_node(Key, Node, Type, Owner, Options) ->
{error, ?ERR_CONFLICT}
end.
%% @spec (Key, Node) -> [mod_pubsub:node()]
%% Key = mod_pubsub:host() | mod_pubsub:jid()
%% @spec (Host, Node) -> [mod_pubsub:node()]
%% Host = mod_pubsub:host() | mod_pubsub:jid()
%% Node = mod_pubsub:pubsubNode()
delete_node(Key, Node) ->
Removed = get_subnodes_tree(Key, Node),
lists:foreach(fun(N) ->
mnesia:delete({pubsub_node, {Key, N}})
end, Removed),
delete_node(Host, Node) ->
Removed = get_subnodes_tree(Host, Node),
lists:foreach(fun(#pubsub_node{nodeid = {_, N}, id = I}) ->
pubsub_index:free(node, I),
mnesia:delete({pubsub_node, {Host, N}})
end, Removed),
Removed.

View File

@ -48,7 +48,7 @@
get_nodes/2,
get_nodes/1,
get_subnodes/3,
get_subnodes_tree/2,
get_subnodes_tree/3,
create_node/5,
delete_node/2
]).
@ -94,14 +94,13 @@ get_node(Host, Node, _From) ->
get_node(Host, Node) ->
#pubsub_node{nodeid = {Host, Node}}.
get_nodes(Key, _From) ->
get_nodes(Key).
%% @spec (Key) -> [pubsubNode()]
%% @spec (Host) -> [pubsubNode()]
%% Host = mod_pubsub:host() | mod_pubsub:jid()
%% @doc <p>Virtual node tree does not handle a node database. Any node is considered
%% as existing. Nodes list can not be determined.</p>
get_nodes(_Key) ->
get_nodes(Host, _From) ->
get_nodes(Host).
get_nodes(_Host) ->
[].
%% @spec (Host, Node, From) -> [pubsubNode()]
@ -109,13 +108,17 @@ get_nodes(_Key) ->
%% Node = mod_pubsub:pubsubNode()
%% From = mod_pubsub:jid()
%% @doc <p>Virtual node tree does not handle parent/child. Child list is empty.</p>
get_subnodes(_Host, _Node, _From) ->
get_subnodes(Host, Node, _From) ->
get_subnodes(Host, Node).
get_subnodes(_Host, _Node) ->
[].
%% @spec (Host, Index) -> [pubsubNode()]
%% Host = mod_pubsub:host()
%% Node = mod_pubsub:pubsubNode()
%% @doc <p>Virtual node tree does not handle parent/child. Child list is empty.</p>
get_subnodes_tree(Host, Node, _From) ->
get_subnodes_tree(Host, Node).
get_subnodes_tree(_Host, _Node) ->
[].
@ -128,11 +131,11 @@ get_subnodes_tree(_Host, _Node) ->
%% @doc <p>No node record is stored on database. Any valid node
%% is considered as already created.</p>
%% <p>default allowed nodes: /home/host/user/any/node/name</p>
create_node(_Host, Node, _Type, Owner, _Options) ->
create_node(Host, Node, _Type, Owner, _Options) ->
UserName = Owner#jid.luser,
UserHost = Owner#jid.lserver,
case Node of
["home", UserHost, UserName | _] -> {error, ?ERR_CONFLICT};
["home", UserHost, UserName | _] -> {error, {virtual, {Host, Node}}};
_ -> {error, ?ERR_NOT_ALLOWED}
end.
@ -141,5 +144,5 @@ create_node(_Host, Node, _Type, Owner, _Options) ->
%% Node = mod_pubsub:pubsubNode()
%% @doc <p>Virtual node tree does not handle parent/child.
%% node deletion just affects the corresponding node.</p>
delete_node(_Host, Node) ->
[Node].
delete_node(Host, Node) ->
[get_node(Host, Node)].

View File

@ -77,24 +77,28 @@
%%% @type affiliation() = none | owner | publisher | outcast.
%%% @type subscription() = none | pending | unconfigured | subscribed.
%%% internal pubsub index table
-record(pubsub_index, {index, last, free}).
%%% @type pubsubNode() = #pubsub_node{
%%% nodeid = {Host::host(), Node::pubsubNode()},
%%% parentid = {Host::host(), Node::pubsubNode()},
%%% nodeidx = int().
%%% type = nodeType(),
%%% owners = [ljid()],
%%% options = [nodeOption()]}.
%%% options = [nodeOption()]}
%%% <p>This is the format of the <tt>nodes</tt> table. The type of the table
%%% is: <tt>set</tt>,<tt>ram/disc</tt>.</p>
%%% <p>The <tt>parentid</tt> and <tt>type</tt> fields are indexed.</p>
-record(pubsub_node, {nodeid,
parentid = {},
type = "",
id,
parent,
type = "default",
owners = [],
options = []
}).
%%% @type pubsubState() = #pubsub_state{
%%% stateid = {ljid(), {Host::host(), Node::pubsubNode()}},
%%% stateid = {ljid(), pubsubNodeId()}},
%%% items = [ItemId::string()],
%%% affiliation = affiliation(),
%%% subscription = subscription()}.
@ -106,11 +110,11 @@
subscription = none
}).
%% @type pubsubItem() = #pubsub_item{
%% itemid = {ItemId::string(), {Host::host(),Node::pubsubNode()}},
%% creation = {ljid(), now()},
%% modification = {ljid(), now()},
%% payload = XMLContent::string()}.
%%% @type pubsubItem() = #pubsub_item{
%%% itemid = {ItemId::string(), pubsubNodeId()}},
%%% creation = {ljid(), now()},
%%% modification = {ljid(), now()},
%%% payload = XMLContent::string()}.
%%% <p>This is the format of the <tt>published items</tt> table. The type of the
%%% table is: <tt>set</tt>,<tt>disc</tt>,<tt>fragmented</tt>.</p>
-record(pubsub_item, {itemid,

View File

@ -0,0 +1,65 @@
%%% ====================================================================
%%% ``The contents of this file are subject to the Erlang Public License,
%%% Version 1.1, (the "License"); you may not use this file except in
%%% compliance with the License. You should have received a copy of the
%%% Erlang Public License along with this software. If not, it can be
%%% retrieved via the world wide web at http://www.erlang.org/.
%%%
%%% Software distributed under the License is distributed on an "AS IS"
%%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%%% the License for the specific language governing rights and limitations
%%% under the License.
%%%
%%% The Initial Developer of the Original Code is ProcessOne.
%%% Portions created by ProcessOne are Copyright 2006-2009, ProcessOne
%%% All Rights Reserved.''
%%% This software is copyright 2006-2009, ProcessOne.
%%%
%%%
%%% @copyright 2006-2009 ProcessOne
%%% @author Christophe Romain <christophe.romain@process-one.net>
%%% [http://www.process-one.net/]
%%% @version {@vsn}, {@date} {@time}
%%% @end
%%% ====================================================================
%% important note:
%% new/1 and free/2 MUST be called inside a transaction bloc
-module(pubsub_index).
-author('christophe.romain@process-one.net').
-include("pubsub.hrl").
-export([init/3, new/1, free/2]).
init(_Host, _ServerHost, _Opts) ->
mnesia:create_table(pubsub_index,
[{disc_copies, [node()]},
{attributes, record_info(fields, pubsub_index)}]).
new(Index) ->
case mnesia:read({pubsub_index, Index}) of
[I] ->
case I#pubsub_index.free of
[] ->
Id = I#pubsub_index.last + 1,
mnesia:write(I#pubsub_index{last = Id}),
Id;
[Id|Free] ->
mnesia:write(I#pubsub_index{free = Free}),
Id
end;
_ ->
mnesia:write(#pubsub_index{index = Index, last = 1, free = []}),
1
end.
free(Index, Id) ->
case mnesia:read({pubsub_index, Index}) of
[I] ->
Free = I#pubsub_index.free,
mnesia:write(I#pubsub_index{free = [Id|Free]});
_ ->
ok
end.