~ubuntu-branches/ubuntu/trusty/ejabberd/trusty-proposed

« back to all changes in this revision

Viewing changes to src/mod_pubsub/node_flat.erl

  • Committer: Bazaar Package Importer
  • Author(s): Gerfried Fuchs, Konstantin Khomoutov, Gerfried Fuchs
  • Date: 2009-12-04 18:22:49 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20091204182249-6jfmdz8878h7oaos
Tags: 2.1.0-1
[ Konstantin Khomoutov ]
* New upstream release (Closes: #519858).
  This also adds support for LDAPS upstream (Closes: #526145).
* Do not depend on cdbs anymore, port debian/rules to dh+quilt,
  remove build dependency on patchutils, use erlang-depends.
* Bump debhelper version to 7, standards base to 3.8.3
* Depend on erlang R13B.
* Recommend imagemagick (for captcha support).
* Remove deprecated patches (ssl.patch patch, dynamic_compile_loglevel.patch,
  ldaps.patch, update.patch, proxy.patch, caps.patch, convert.patch,
  s2s.patch).
* Replace mod_ctlextra with mod_admin_extra.
* Use upstream inetrc file.
* Bring debian/ejabberd.cfg and ejabberdctl in sync with upstream.
* Update ejabberdctl manual page.
* Provide NEWS file.
* Rework README.Debian:
  * Group all information into sections.
  * Describe issues with epam binary (Closes: #502791).
  * Discuss how to use DBMS backends (Closes: #540915, #507144).
  * Discuss upgrading from 2.0.x series.
* Implement PID file management (Closes: #519858).
* Make logrotate process all files matching "*.log".
* Improve init script:
  * Make init script LSB-compliant.
  * Implement "live" target which allows to run ejabberd in foreground.
* Make captcha.sh use bash explicitly.
* Rework node-generation for ejabberdctl to fix ejabberd's atom table
  overflows while preserving the possibility to run several versions
  of ejabberdctl concurrently as before.
* Add webadmin patch restoring compatibility with Erlang/OTP <= R12B-4.
* Integrate upstream patch for EJAB-1106.
* Add upstream patch for EJAB-1098.
* Add upstream patch for EJAB-1045.
* Add Konstantin Khomoutov to uploaders.
* Add Japanese debconf translation (thanks to Hideki Yamane)
  (Closes: #558071).

[ Gerfried Fuchs ]
* Build-Depend on po-debconf so po2debconf can be called.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%%% ====================================================================
 
2
%%% ``The contents of this file are subject to the Erlang Public License,
 
3
%%% Version 1.1, (the "License"); you may not use this file except in
 
4
%%% compliance with the License. You should have received a copy of the
 
5
%%% Erlang Public License along with this software. If not, it can be
 
6
%%% retrieved via the world wide web at http://www.erlang.org/.
 
7
%%% 
 
8
%%% Software distributed under the License is distributed on an "AS IS"
 
9
%%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
 
10
%%% the License for the specific language governing rights and limitations
 
11
%%% under the License.
 
12
%%% 
 
13
%%% The Initial Developer of the Original Code is ProcessOne.
 
14
%%% Portions created by ProcessOne are Copyright 2006-2009, ProcessOne
 
15
%%% All Rights Reserved.''
 
16
%%% This software is copyright 2006-2009, ProcessOne.
 
17
%%%
 
18
%%% @copyright 2006-2009 ProcessOne
 
19
%%% @author Christophe Romain <christophe.romain@process-one.net>
 
20
%%%   [http://www.process-one.net/]
 
21
%%% @version {@vsn}, {@date} {@time}
 
22
%%% @end
 
23
%%% ====================================================================
 
24
 
 
25
-module(node_flat).
 
26
-author('christophe.romain@process-one.net').
 
27
 
 
28
-include("pubsub.hrl").
 
29
-include("jlib.hrl").
 
30
 
 
31
-behaviour(gen_pubsub_node).
 
32
 
 
33
%% API definition
 
34
-export([init/3, terminate/2,
 
35
         options/0, features/0,
 
36
         create_node_permission/6,
 
37
         create_node/2,
 
38
         delete_node/1,
 
39
         purge_node/2,
 
40
         subscribe_node/8,
 
41
         unsubscribe_node/4,
 
42
         publish_item/6,
 
43
         delete_item/4,
 
44
         remove_extra_items/3,
 
45
         get_entity_affiliations/2,
 
46
         get_node_affiliations/1,
 
47
         get_affiliation/2,
 
48
         set_affiliation/3,
 
49
         get_entity_subscriptions/2,
 
50
         get_node_subscriptions/1,
 
51
         get_subscriptions/2,
 
52
         set_subscriptions/4,
 
53
         get_pending_nodes/2,
 
54
         get_states/1,
 
55
         get_state/2,
 
56
         set_state/1,
 
57
         get_items/6,
 
58
         get_items/2,
 
59
         get_item/7,
 
60
         get_item/2,
 
61
         set_item/1,
 
62
         get_item_name/3,
 
63
         node_to_path/1,
 
64
         path_to_node/1
 
65
        ]).
 
66
 
 
67
 
 
68
init(Host, ServerHost, Opts) ->
 
69
    node_hometree:init(Host, ServerHost, Opts).
 
70
 
 
71
terminate(Host, ServerHost) ->
 
72
    node_hometree:terminate(Host, ServerHost).
 
73
 
 
74
options() ->
 
75
    [{deliver_payloads, true},
 
76
     {notify_config, false},
 
77
     {notify_delete, false},
 
78
     {notify_retract, true},
 
79
     {persist_items, true},
 
80
     {max_items, ?MAXITEMS},
 
81
     {subscribe, true},
 
82
     {access_model, open},
 
83
     {roster_groups_allowed, []},
 
84
     {publish_model, publishers},
 
85
     {notification_type, headline},
 
86
     {max_payload_size, ?MAX_PAYLOAD_SIZE},
 
87
     {send_last_published_item, on_sub_and_presence},
 
88
     {deliver_notifications, true},
 
89
     {presence_based_delivery, false}].
 
90
 
 
91
features() ->
 
92
    node_hometree:features().
 
93
 
 
94
%% use same code as node_hometree, but do not limite node to
 
95
%% the home/localhost/user/... hierarchy
 
96
%% any node is allowed
 
97
create_node_permission(Host, ServerHost, _Node, _ParentNode, Owner, Access) ->
 
98
    LOwner = jlib:jid_tolower(Owner),
 
99
    Allowed = case LOwner of
 
100
        {"", Host, ""} ->
 
101
            true; % pubsub service always allowed
 
102
        _ ->
 
103
            acl:match_rule(ServerHost, Access, LOwner) =:= allow
 
104
    end,
 
105
    {result, Allowed}.
 
106
 
 
107
create_node(NodeId, Owner) ->
 
108
    node_hometree:create_node(NodeId, Owner).
 
109
 
 
110
delete_node(Removed) ->
 
111
    node_hometree:delete_node(Removed).
 
112
 
 
113
subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup, Options) ->
 
114
    node_hometree:subscribe_node(NodeId, Sender, Subscriber, AccessModel, SendLast, PresenceSubscription, RosterGroup, Options).
 
115
 
 
116
unsubscribe_node(NodeId, Sender, Subscriber, SubID) ->
 
117
    node_hometree:unsubscribe_node(NodeId, Sender, Subscriber, SubID).
 
118
 
 
119
publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload) ->
 
120
    node_hometree:publish_item(NodeId, Publisher, Model, MaxItems, ItemId, Payload).
 
121
 
 
122
remove_extra_items(NodeId, MaxItems, ItemIds) ->
 
123
    node_hometree:remove_extra_items(NodeId, MaxItems, ItemIds).
 
124
 
 
125
delete_item(NodeId, Publisher, PublishModel, ItemId) ->
 
126
    node_hometree:delete_item(NodeId, Publisher, PublishModel, ItemId).
 
127
 
 
128
purge_node(NodeId, Owner) ->
 
129
    node_hometree:purge_node(NodeId, Owner).
 
130
 
 
131
get_entity_affiliations(Host, Owner) ->
 
132
    node_hometree:get_entity_affiliations(Host, Owner).
 
133
 
 
134
get_node_affiliations(NodeId) ->
 
135
    node_hometree:get_node_affiliations(NodeId).
 
136
 
 
137
get_affiliation(NodeId, Owner) ->
 
138
    node_hometree:get_affiliation(NodeId, Owner).
 
139
 
 
140
set_affiliation(NodeId, Owner, Affiliation) ->
 
141
    node_hometree:set_affiliation(NodeId, Owner, Affiliation).
 
142
 
 
143
get_entity_subscriptions(Host, Owner) ->
 
144
    node_hometree:get_entity_subscriptions(Host, Owner).
 
145
 
 
146
get_node_subscriptions(NodeId) ->
 
147
    node_hometree:get_node_subscriptions(NodeId).
 
148
 
 
149
get_subscriptions(NodeId, Owner) ->
 
150
    node_hometree:get_subscriptions(NodeId, Owner).
 
151
 
 
152
set_subscriptions(NodeId, Owner, Subscription, SubId) ->
 
153
    node_hometree:set_subscriptions(NodeId, Owner, Subscription, SubId).
 
154
 
 
155
get_pending_nodes(Host, Owner) ->
 
156
    node_hometree:get_pending_nodes(Host, Owner).
 
157
 
 
158
get_states(NodeId) ->
 
159
    node_hometree:get_states(NodeId).
 
160
 
 
161
get_state(NodeId, JID) ->
 
162
    node_hometree:get_state(NodeId, JID).
 
163
 
 
164
set_state(State) ->
 
165
    node_hometree:set_state(State).
 
166
 
 
167
get_items(NodeId, From) ->
 
168
    node_hometree:get_items(NodeId, From).
 
169
 
 
170
get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
 
171
    node_hometree:get_items(NodeId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
 
172
 
 
173
get_item(NodeId, ItemId) ->
 
174
    node_hometree:get_item(NodeId, ItemId).
 
175
 
 
176
get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId) ->
 
177
    node_hometree:get_item(NodeId, ItemId, JID, AccessModel, PresenceSubscription, RosterGroup, SubId).
 
178
 
 
179
set_item(Item) ->
 
180
    node_hometree:set_item(Item).
 
181
 
 
182
get_item_name(Host, Node, Id) ->
 
183
    node_hometree:get_item_name(Host, Node, Id).
 
184
 
 
185
node_to_path(Node) ->
 
186
    [binary_to_list(Node)].
 
187
 
 
188
path_to_node(Path) ->
 
189
    case Path of
 
190
    % default slot
 
191
    [Node] -> list_to_binary(Node);
 
192
    % handle old possible entries, used when migrating database content to new format
 
193
    [Node|_] when is_list(Node) -> list_to_binary(string:join([""|Path], "/"));
 
194
    % default case (used by PEP for example)
 
195
    _ -> list_to_binary(Path)
 
196
    end.